floating point verification using is?

Steven Schveighoffer schveiguy at yahoo.com
Fri Dec 18 11:50:51 PST 2009


On Fri, 18 Dec 2009 14:47:13 -0500, bearophile <bearophileHUGS at lycos.com>  
wrote:

> Steven Schveighoffer:
>> float x;
>>
>> assert(isIdentical(x, float.init)); // fails
>>
>> This is what I'm trying to test.  It has to do with the fact that
>> float.init is a literal, and I think it's automatically converted to
>> real.init.
>
> Try this:
> http://www.digitalmars.com/d/2.0/phobos/std_math.html#isNaN

That's great, but I'm trying to verify that my array building code  
correctly appends T.init.  isNaN returns true no matter what the bit  
representation of nan is.  I want to *specifically* compare bit  
representations of floating point numbers to ensure the code I'm writing  
is doing what I think it's doing.  It shouldn't be this complicated to do  
that.

-Steve


More information about the Digitalmars-d-learn mailing list