Re: Pure newbie :(
Re: Pure newbie :(
- Subject: Re: Pure newbie :(
- From: "Anthony Byrne" <email@hidden>
- Date: Tue, 11 Nov 2003 16:48:46 -0500
>
Denis Vaillant wrote:
>
Hello,
>
>
I do not understand why the comparison does not work :
>
>
rxNext1 = 0.400000;
>
>
if(rxNext1==0.400000)
>
{
>
NSLog(@"Should work :(");
>
}
>
>
PS : rxNext1 is a float.
Hi Denis,
While what you wrote makes perfect sense on the surface, you have to think
about the underlying representation of floating point numbers. After all,
there's an infinite number of "real" numbers between 0.0 and 1.0 that must
be somehow represented in a finite number of bits. So all floating point
representations are always an approximation of some "real" number. In a
nutshell, comparing floating point values for "equality" is never reliable.
Regards,
Tony Byrne
_______________________________________________
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.