float.max + 1.0 does not overflow

2017-12-27 Thread rumbu via Digitalmars-d-learn
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.

Re: float.max + 1.0 does not overflow

2017-12-27 Thread Benjamin Thaut via Digitalmars-d-learn
On Wednesday, 27 December 2017 at 13:40:28 UTC, rumbu wrote: 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

Re: float.max + 1.0 does not overflow

2017-12-28 Thread Dave Jones via Digitalmars-d-learn
On Wednesday, 27 December 2017 at 14:14:42 UTC, Benjamin Thaut wrote: On Wednesday, 27 December 2017 at 13:40:28 UTC, rumbu wrote: Is that normal? It computes the difference between float.max and the next smaller reprensentable number in floating point. The difference printed by the program is