[cfp-interest 3908] Re: Trailing Decimal Exponent on a Hexadecimal standard floating type

Trevor Gross tg at trevorgross.com
Tue Apr 21 04:10:11 PDT 2026


On 2026-04-21 05:56, Paul Zimmermann wrote:
> 
> I take the opportunity to ask whether one should standardize the way
> hexadecimal numbers are printed: 0x1.5abp+23 or 0x2.b56p+22 or
> 0x5.6acp+21 or 0xa.d58p+20. I prefer 0x1.5abp+23 since the magnitude
> is easier to guess.
> 
> Rationale: different libraries use different conventions, which makes
> it difficult to compare results.

There has been some interesting discussion on the MPFR list in the past,
Vincent posted a summary of alternatives at [1] (you and I were both on
that thread).

I am also a fan of starting with '0x1.' because it feels closer to the
canonical expansion of '2^23 * 1.5abp' (mixing bases, of course). One
other advantage is that, at least for double, the significand digits 
line
up with the bitwise representation (0x1.123456789abcdp+0 is
0x3ff123456789abcd).

- Trevor

> There is also the issue of subnormal numbers. Some libraries print
> them as say 0x0.000000000001p-1074, which is a good way to see it
> is a subnormal.
> 
> Paul

[1]: https://sympa.inria.fr/sympa/arc/mpfr/2025-02/msg00007.html


More information about the cfp-interest mailing list