• 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: Strange behavior of -Wfloat-equal on clang (Xcode 5)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Strange behavior of -Wfloat-equal on clang (Xcode 5)


  • Subject: Re: Strange behavior of -Wfloat-equal on clang (Xcode 5)
  • From: Asiga Nael <email@hidden>
  • Date: Fri, 03 Jan 2014 23:29:48 +0000 (GMT)

 On 3 Jan 2014, at 2:50 PM, Fritz
 Anderson <email@hidden>
 wrote:
 > if (valueOrZero != 0.0) ratio = fNumerator / valueOrZero;

Just to add some light to this use I was doing of floating point equality comparisons for avoiding division by zero, I searched the web and found that -contrary to my belief- this test is "unsafe" too: while it's true that if a fp number isn't exactly zero it won't produce a division by zero, however, it can still generate infinity if it's a denormal (or subnormal according to current IEEE naming). So, the really safe way is to use the isnormal() macro before doing the division: this will guarantee there's no division by zero and there's no infinity result, if I've read correctly some web pages.

asiga


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Prev by Date: Re: Connections Inspector sometimes omits Sent Actions
  • Next by Date: Re: Strange problems using std::string and C++0x
  • Previous by thread: Re: Strange behavior of -Wfloat-equal on clang (Xcode 5)
  • Next by thread: Connections Inspector sometimes omits Sent Actions
  • Index(es):
    • Date
    • Thread