If you swap the line to
writefln("nextUp of %a is %a", 1.0L, 1.0L.nextUp());
you get the same result as the second case.
On 02/16/2014 01:42 PM, Andrej Mitrovic wrote:
> -
> import std.math;
> import std.stdio;
>
> void main()
> {
> writefln("nextUp of %a is %a", 1.0, 1.0.nextUp());
That line uses doubles.
>
> real num = 1.0;
> writefln("nextUp of %a is %a", num, num.nextUp());
That one uses r
On 2/16/14, Andrej Mitrovic wrote:
> Any idea why the results are different?
Interestingly the literal versions end up calling nextUp which takes a
double rather than a real. So nextUp(1.0) calls the double overload,
nextUp(num) calls the real overload. Mystery solved.
-
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.1p+0
nextUp of 0x1p+0 is 0x1.0002p+0
Any