Re: Strange behavior of -Wfloat-equal on clang (Xcode 5)
Re: Strange behavior of -Wfloat-equal on clang (Xcode 5)
- Subject: Re: Strange behavior of -Wfloat-equal on clang (Xcode 5)
- From: Sean McBride <email@hidden>
- Date: Fri, 03 Jan 2014 15:08:15 -0500
- Organization: Rogue Research Inc.
On Fri, 3 Jan 2014 19:54:18 +0000, Asiga Nael said:
>>Not every decimal number can be expressed exactly as a floating point
>number. You can see that here:
>><http://www.h-schmidt.net/FloatConverter/>
>
>According to such page, 2.1 has an exact representation in the IEEE
>format.
How do you conclude that? In fact, the page shows the exact opposite. The closest values are 2.0999999046325684 and 2.1000001430511475.
>Anyway, that's not the point. The point is that a fp comparison
>for equality isn't safe unless both operands aren't the result of fp
>math. If any of them is the result of a math operation, the comparison
>is unsafe even if one of the operands is a literal with an exact
>representation.
>
>Give me a value that can be stored with an exact representation, let me
>store it on a floating point variable, and let me do a few operations
>which in theory should leave the value unmodified, and I'll manage to
>get a value slightly different from the original.
>
>Any use I imagine of it is unsafe (end conditions for loops, branching
>depending on an fp math result, etc...)
I wasn't arguing any of that. Your position is reasonable, but is not what the clang developers have apparently chosen. You can lobby them and/or use gcc instead.
Cheers,
--
____________________________________________________________
Sean McBride, B. Eng email@hidden
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
_______________________________________________
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