floating point verification using is?

div0 div0 at users.sourceforge.net
Fri Dec 18 10:49:18 PST 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Steven Schveighoffer wrote:
> If I have 2 identical floating point values, how do I ensure they are
> binary equivalents of eachother?  I'm trying to write some
> unittest/assert code, and it's not exactly trivial.
> 
> I thought 'a is b' would work, but it just morphs into a == b, which
> isn't helpful.  Why doesn't 'is' just do a bit compare for floating points?
> 
> -Steve

Just out of curiosity; how many cases are there where a == b
and they have different bit patterns?

I can only think of +-0.

Otherwise you can only get that with denormalised floats;
which you won't get on an x86 processor.

- --
My enormous talent is exceeded only by my outrageous laziness.
http://www.ssTk.co.uk
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFLK86uT9LetA9XoXwRAvtsAKDDoX6EzXj+wOIgTVHDzkRF0vXGsgCdH6tX
QLvFQxYyjIwk7Qxi13VyrCI=
=M18X
-----END PGP SIGNATURE-----


More information about the Digitalmars-d-learn mailing list