floating point conversion

bearophile via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jun 1 05:45:25 PDT 2014


Martin Krejcirik:

>     float a = 1.23f;
>     double b = to!float("1.23");
>     assert (a == b); // ???
> }
>
> Should the assert fail or not ? (Please reply without trying 
> first).

It's a bad question. Generally to compare floating point values 
for equality use std.math.feqrel.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list