From: Keith Packard <keithp@keithp.com>
To: Brian Inglis <Brian.Inglis@SystematicSw.ab.ca>, newlib@sourceware.org
Subject: Re: gcc 11.1.0: printf("%.43f\n", 0x1.52f8a8e32e982p-140): printed value is incorrectly rounded
Date: Thu, 04 Nov 2021 19:54:54 -0700 [thread overview]
Message-ID: <87r1bvtipt.fsf@keithp.com> (raw)
In-Reply-To: <6b742e91-5a56-8a4d-c9a5-b33d2b33bb66@SystematicSw.ab.ca>
[-- Attachment #1: Type: text/plain, Size: 1624 bytes --]
Brian Inglis <Brian.Inglis@SystematicSw.ab.ca> writes:
> Keith,
>
> I believe the implementation uses tables: that could be an issue in the
> embedded world; can you comment on the table space required for 32, 64,
> 128 bits?
I don't have a long double implementation of the ryu code; 128 bit
doubles would require 256 bit arithmetic (add/mul, fortunately no
divide), and a bunch of analysis to generate the table values. The
sample code on github only provides 32- and 64- bit
implementations. Picolibc currently has an imprecise printf
implementation for long double that works for Intel (80 bit) Risc-V
(IEEE 128 bit) and Power PC ('double double' 128-bit).
The total size of printf using the Ryu code is substantially smaller
than that required by the current newlib bits as it doesn't drag in the
arbitrary precision functions. The tables are 830 bytes.
I did a presentation in September at the Embedded Linux Conference where
I showed some complete binary numbers that involved printf
#include <stdio.h>
void main(void)
{
printf("%g\n", 355.0/113.0);
}
On Cortex M3 hardware (an STM32L152 discovery board):
ROM RAM
Picolibc 64-bit 6872 24
Picolibc 32-bit 5360 24
Newlib 64-bit 15584 1200+1084
The newlib number for RAM includes both static and sbrk amounts;
picolibc doesn't call sbrk for this example. These are complete
examples, including semihosting code to display the numbers using
openocd on the target hardware.
--
-keith
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
next prev parent reply other threads:[~2021-11-05 2:54 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAL9Mx1uMOz2wfqbMpD_xfA=D9JkpFzVz6AR_DKHK34AvrGOP6w@mail.gmail.com>
2021-11-03 21:26 ` Fwd: " Pavel M
2021-11-04 12:24 ` Corinna Vinschen
2021-11-04 16:48 ` Keith Packard
2021-11-04 17:27 ` Dave Nadler
2021-11-04 17:58 ` Keith Packard
2021-11-04 21:28 ` Brian Inglis
2021-11-05 2:54 ` Keith Packard [this message]
2021-11-05 16:00 ` Steven Abner
2021-11-06 12:06 ` Steven Abner
2021-11-06 23:25 ` Steven Abner
2021-11-08 9:57 ` Corinna Vinschen
2021-11-04 20:57 ` Corinna Vinschen
2021-11-28 7:43 ` Takashi Yano
2021-11-28 12:38 ` Takashi Yano
2021-11-28 13:16 ` Takashi Yano
2021-11-29 10:56 ` Takashi Yano
2021-11-29 14:24 ` Takashi Yano
2021-11-29 15:55 ` Corinna Vinschen
2021-11-30 10:51 ` Takashi Yano
2021-11-30 15:09 ` Corinna Vinschen
2021-11-30 20:38 ` Takashi Yano
2021-11-30 21:17 ` Takashi Yano
2021-12-06 9:53 ` Corinna Vinschen
2021-12-06 10:26 ` Takashi Yano
2021-12-01 12:05 ` Takashi Yano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87r1bvtipt.fsf@keithp.com \
--to=keithp@keithp.com \
--cc=Brian.Inglis@SystematicSw.ab.ca \
--cc=newlib@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).