Hexadecimal "%Fa" printing does not work properly
wgillam at fiu.edu
Thu Oct 25 19:38:45 UTC 2018
The "C99 style %a hex float" printing of floating point numbers in GMP does not seem to work properly. For example, as the attached example code demonstrates, 2 will be printed as
when using gmp_printf("%.2Fa"). This is not proper base 2 scientific notation---the mantissa is not in the interval [1,2). The correct
printing should be
as would be output by printf("%.2a",2.0) (cf. the included example code). The error is presumably due to the funny way the "C99 style %a hex float" printing mixes base 2 and base 16 by using base 16 as a shorthand for the fractional part of the mantissa (but it should ONLY be used for that mild shorthand purpose and the integer part of the mantissa should always be 1, though gmp_printf chooses the integer part of the mantissa in 1,...,15 = 1,...,F).
This printing error is carried over to MPFR's mpfr_printf as well...
Linux [Name Withheld] 4.15.0-36-generic #39-Ubuntu SMP [Date Withheld] x86_64 x86_64 x86_64 GNU/Linux
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 485 bytes
More information about the gmp-bugs