floating point verification using is?
Stewart Gordon
smjg_1998 at yahoo.com
Sun Dec 27 13:37:53 PST 2009
Steven Schveighoffer wrote:
<snip>
> Are you still working on this? :) I think this proves my point. The
> compiler does not provide an easy way to compare floats bitwise, so this
> means convoluted hard-to-write code. When we have two operators that do
> equality -- and one of those means bitwise compare in all other contexts
> -- I think this is a no-brainer.
I entirely agree.
I've identified these cases in which float equality disagrees with
bitwise equality:
- one is +0, one is -0
- both are NaNs, identically signed
- both are infinity, identically signed
In each case, is just does the same as ==.
Indeed, isIdentical is an ugly workaround for this, apparently created
instead of sanitising the definition of is to avoid the minuscule amount
of code breakage that the latter would effect.
Stewart.
More information about the Digitalmars-d-learn
mailing list