Hexadecimal "%Fa" printing does not work properly

Vincent Lefevre vincent at vinc17.net
Fri Oct 26 06:34:15 UTC 2018


On 2018-10-25 19:38:45 +0000, William Gillam wrote:
> GMP Developers:
> 
> 
> 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
> 
> 
> 0x2.00p+0
> 
> 
> 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
> 
> 
> 0x1.00p+1

No, 0x2.00p+0 is correct. The only requirement is that the first digit
be non-zero. C99 specifies: "where there is one hexadecimal digit
(which is nonzero if the argument is a normalized floating-point number
and is otherwise unspecified) before the decimal-point character".

-- 
Vincent Lefèvre <vincent at vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


More information about the gmp-bugs mailing list