www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16344] New: Real FP magic on windows

https://issues.dlang.org/show_bug.cgi?id=16344

          Issue ID: 16344
           Summary: Real FP magic on windows
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: greensunny12 gmail.com

Consider the following program:

void main
{
    import std.stdio;
    import std.math;
    alias S = real;
    S f = 0x1.14ada3f2c1d77p-48;
    writefln("up: %a", f.nextUp);
    writefln("down: %a", f.nextDown);
    writefln("f: %a", f);
}

On Windows it prints the same number.

```
up: 0x1.14ada3f2c1d77p-48
down: 0x1.14ada3f2c1d77p-48
f: 0x1.14ada3f2c1d77p-48
```

On Linux for 32-bit as well as 64-bit it prints the expected result:

```
up: 0x8.a56d1f960ebb801p-51
down: 0x8.a56d1f960ebb7ffp-51
f: 0x8.a56d1f960ebb8p-51
```

If I digged correctly, core.stdc.stdio.fwrite is used under the hood of
std.format (and thus writef). Unfortunately I don't have a Windows machine to
test this further. 

From the documentation for '%a':
 If there is no Precision, as many hexadecimal digits as necessary to exactly
represent the mantissa are generated.
--
Jul 31 2016