Comparing double and float values

Abid H. Mujtaba abid.naqvi83 at gmail.com
Thu May 12 01:03:34 PDT 2011


I am working through "The D Programming Language" by Andrei
Alexandrescu and one of the examples compared an array of doubles
with an array of floats in a unittest (pg. 143 while discussing
function overloading). The unittest failed when I compiled the file
using rdmd. I simplified the problem and the following code will not
compile:

// Code in file test.d

unittest
{
   double x = 3.2 ;
   float y = 3.2 ;

   assert( x == y ) ;
}

Running 'rdmd --main -unittest test.d' results in:

core.exception.AssertError at test(6): unittest failure


More information about the Digitalmars-d mailing list