Strange result with nextUp for reals

Andrej Mitrovic andrej.mitrovich at
Sun Feb 16 13:42:19 PST 2014

import std.math;
import std.stdio;

void main()
    writefln("nextUp of %a is %a", 1.0, 1.0.nextUp());

    real num = 1.0;
    writefln("nextUp of %a is %a", num, num.nextUp());

This prints:

nextUp of 0x1p+0 is 0x1.0000000000001p+0
nextUp of 0x1p+0 is 0x1.0000000000000002p+0

Any idea why the results are different?

More information about the Digitalmars-d-learn mailing list