float.max + 1.0 does not overflow

rumbu rumbu at rumbu.ro
Wed Dec 27 13:40:28 UTC 2017


Is that normal?

use std.math;
float f = float.max;
f += 1.0;
assert(IeeeFlags.overflow) //failure
assert(f == float.inf) //failure, f is in fact float.max

On the contrary, float.max + float.max will overflow. The 
behavior is the same for double and real.




More information about the Digitalmars-d-learn mailing list