gcc 11.1.0: printf("%.43f\n", 0x1.52f8a8e32e982p-140): printed value is incorrectly rounded

Steven Abner pheonix.sja@att.net
Sat Nov 6 12:06:05 GMT 2021

  I didn't mean to stop the conversion! Here is a butchered, self 
contained use.
Hopefully this provides better means to evaluate. Low precision code 
since I assume embedded systems won't use. In case of not obvious, 
entry from
printf() into realto functions expected a 64 byte buffer to write to. 
realto functions
has a static buffer to cover double range. It uses malloc() if it 
determines that
with localization and precision, if it needs to increase past 64 byte 
return. realto
functions includes decimal encoding of up to 4 byte utf8 encoding, 
which at the
time of writing no script came close to, think 2 bytes was max?
  There is commented out code for 32 bit float, but not sure would ever 
get used.

  sample use:
steven@steven-ryzen:~/Development/Projects$ gcc  newlib_printf_demo.c 
-o nldemo
steven@steven-ryzen:~/Development/Projects$ ./nldemo

-------------- next part --------------
A non-text attachment was scrubbed...
Name: newlib_printf_demo.c
Type: text/x-csrc
Size: 70768 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/newlib/attachments/20211106/30ce9990/attachment-0001.bin>

More information about the Newlib mailing list