floatValue of nil NSNumber unreliable (was Re: Bug or feature?)
floatValue of nil NSNumber unreliable (was Re: Bug or feature?)
- Subject: floatValue of nil NSNumber unreliable (was Re: Bug or feature?)
- From: Daniel Jalkut <email@hidden>
- Date: Tue, 14 Feb 2006 13:21:55 -0500
Interesting. I just took your snippet and also reproduced funny
behavior (identical config to yours, incidentally).
What's interesting is the "random number" seems to correspond to the
last "real float NSNumber" used.
For instance:
float fval=0.0;
NSNumber *aNumber=nil;
NSNumber *secondNumber = [NSNumber numberWithFloat:0.5];
fval=[aNumber floatValue];
NSLog(@"fval is %f",fval);
fval is always 0.5.
It sounds like a bug to me. Maybe somebody from Apple will have an
opinion about this.
Daniel
On Feb 14, 2006, at 1:14 PM, M. Carlson wrote:
This is using Xcode 2.2, OSX 10.4.4, PM G5 2GHz x 2. When I run
this, I get random numbers in fval. This came about when I was
retrieving a value from an NSDictionary, but there was no entry in
the dictionary for the key I was using. I ended up getting wild
values for fval, and finally boiled it down to this little snippet,
which seems odd to me.
So, am I misunderstanding something about Cocoa, or is it some
Xcode setting I'm supposed to be using so I get 0 back?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden