• 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: Best way to compare CGFloats (Rick B.)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Best way to compare CGFloats (Rick B.)


  • Subject: Re: Best way to compare CGFloats (Rick B.)
  • From: Michael Ash <email@hidden>
  • Date: Wed, 30 Jun 2010 12:37:53 -0400

On Wed, Jun 30, 2010 at 11:11 AM, Alastair Houghton
<email@hidden> wrote:
> On 30 Jun 2010, at 15:56, Frederick Bartram wrote:
>
>> Hope that I am not being too pedantic but imo you should never test for 'equality' ('==') when using machine real data types.
>
> Sometimes you really do want binary equivalence, and in that case == may be the right thing to use.

While we're being pedantic, note that == is not always the same as
"binary equivalence". For example, 0.0 == -0.0, and x != x when x =
NAN.

Using == can make sense when you know that your values are exact
integers, which is not an uncommon scenario, but neither is it the
usual one.

Mike
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Best way to compare CGFloats (Rick B.)
      • From: Alastair Houghton <email@hidden>
References: 
 >Re: Best way to compare CGFloats (Rick B.) (From: Frederick Bartram <email@hidden>)
 >Re: Best way to compare CGFloats (Rick B.) (From: Alastair Houghton <email@hidden>)

  • Prev by Date: Re: Best way to compare CGFloats (Rick B.)
  • Next by Date: Calling javascript from Cocoa 'facelessly'
  • Previous by thread: Re: Best way to compare CGFloats (Rick B.)
  • Next by thread: Re: Best way to compare CGFloats (Rick B.)
  • Index(es):
    • Date
    • Thread