discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Wrong Description from NSNumber


From: Richard Frith-Macdonald
Subject: Re: Wrong Description from NSNumber
Date: Mon, 12 Nov 2001 12:34:12 +0000

On Monday, November 12, 2001, at 12:15 PM, Gerrit Van Dyk wrote:

I have finished porting our backend system to gnustep. Our system makes use of NSNumber's description method quite a lot. I am sorry to say but this returns total garbage from an implementation point of view. If I construct
a
number from a float ie [NSNumber numberWithFloat:1.5] the description
method
returns "0.0000000" which is definitely not 1.5. If I construct a number
from a short ie [NSNumber numberWithShort:25] the description method
returns
"-1073807335".

After futher investigation I found that numberWithFloat: does indeed work
correctly, I initially did this in gdb and it seems that something went
wrong there. The numberWithShort: does give wrong results.

I did the following:

str = [NSString stringWithFormat:@"%hd",25];
printf("%s",[str cString]);

This yielded:
-1073807335

printf("%hd",25); yielded:
25

The %hd i took from the NSNumber descriptionWithLocale: method.

Where can I find futher information on this, I am temporarily changing the
formatting in NSNumber to be %d instead of %hd.

Good ... I found a bug in %hd formatting, but had been unable to find anything
wrong with floats.

I'll commit some changes to CVS shortly.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]