• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Pure newbie :(
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Prev by Date: Re: NSPopUpButtonCell?
  • Next by Date: Disabling sorting in NSTableView
  • Previous by thread: Re: Pure newbie :(
  • Next by thread: Re: Pure newbie :(
  • Index(es):
    • Date
    • Thread