Always false float comparisons

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Mon May 9 02:10:19 PDT 2016


Don Clugston pointed out in his DConf 2016 talk that:

     float f = 1.30;
     assert(f == 1.30);

will always be false since 1.30 is not representable as a float. However,

     float f = 1.30;
     assert(f == cast(float)1.30);

will be true.

So, should the compiler emit a warning for the former case?


More information about the Digitalmars-d mailing list