On Fri, 10 Sep 2021, Patrick Northon via Mingw-w64-public wrote:

Finally, here's the patch to change double formatting in hexadecimal. As you
can see, I managed to find a way to fix it with little changes. Only a few
minor adjustments needed.

Awesome! I appreciate that you managed to reuse the whole formatting function as is.

In trying out a couple different cases comparing them to glibc, I spotted one difference, reproducible with this snippet:

    union {
        double f;
        uint64_t i;
    } u = { .i = 0x0008000000000000ULL };
    printf("%a\n", u.f);
    printf("%.0a\n", u.f);

With your implementation, this prints:

0x0.8p-1022
0x1p-1022

However with glibc, this prints:

0x0.8p-1022
0x0p-1022

This looks wrong to me though, and I'd say your version is correct. Surprisingly though, UCRT also prints the same here. As those probably don't share the implementation, it would imply that there's some reason for it (that I don't see).

On macOS, this case prints

0x1p-1023
0x1p-1023

which is another correct way of handling it (although different from how glibc handles denormals).

// Martin




_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to