floating point verification using is?
smjg_1998 at yahoo.com
Sun Dec 27 13:37:53 PST 2009
Steven Schveighoffer wrote:
> 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
- 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.
More information about the Digitalmars-d-learn