Re: [SOLVED...but] Re: Storing NaN in NSMutableArray ?
Re: [SOLVED...but] Re: Storing NaN in NSMutableArray ?
- Subject: Re: [SOLVED...but] Re: Storing NaN in NSMutableArray ?
- From: "Kubernan @ 10191 Tec." <email@hidden>
- Date: Wed, 10 Mar 2004 23:12:18 +0100
Hum ... very strange :
This code :
if ( [[anArray objectAtIndex:index] isEqual:[NSDecimalNumber
notANumber]])
{
NSLog(@"Value of anArray at Index %d = %f", index, [[anArray
objectAtIndex:index] doubleValue]);
NSLog(@"Oh no !!");
return TRUE;
}
Gives :
2004-03-10 22:40:11.561 STTester[2306] Value of anArray at Index 0 =
0.000000
2004-03-10 22:40:11.561 STTester[2306] Oh no !!
+0.0 == NaN ??
Chris.
Le 10 mars 04, ` 22:02, Marco Scheurer a icrit :
>
>
On Mar 10, 2004, at 9:23 PM, Kubernan @ 10191 Tec. wrote:
>
>
> Re,
>
>
>
> I'm sorry to say that
>
>> [anArray addObject:[NSDecimalNumber notANumber]];
>
>
>
> was never called :-(
>
> Now it works : NSLog prints NaN. But the test below :
>
>
>
> "if ([[anArray objectAtIndex:0] isEqualTo:[NSDecimalNumber
>
> notANumber]])"
>
> always returns TRUE even if the the value at the index 0 is a
>
> NSNumber equal to +0.0 (that is not NaN value).
>
> (same result with "isEqual" instead of "isEqualTo").
>
>
>
> I also tried :
>
> "if ([[anArray objectAtIndex:0] compare:[NSDecimalNumber notANumber]]
>
> ...)"
>
> With no success.
>
>
>
> Why +0.0 is equal to NaN ??
>
>
Because there's still something wrong in your code, I would say. How
>
do you get "a NSNumber equal to +0.0" ? This is what the most
>
elementary tests give:
>
>
should ([[NSDecimalNumber notANumber] isEqual:[NSDecimalNumber
>
notANumber]]);
>
shouldnt ([[NSDecimalNumber notANumber] isEqual:[NSNumber
>
numberWithFloat:0.0]]);
>
>
Test Case '-[TestLab testNaN]' passed (0.001 seconds).
>
>
Marco Scheurer
>
Sen:te, Lausanne, Switzerland http://www.sente.ch
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.