From: Peter Ammon <corydoras@ridiculousfish.com>
To: musl@lists.openwall.com
Subject: Re: [musl] [PATCH] Fix printf hex float formatting with precision
Date: Sat, 13 Apr 2024 09:00:19 -0700 [thread overview]
Message-ID: <07FBEE99-778B-4A8C-B968-077B4515E000@ridiculousfish.com> (raw)
In-Reply-To: <20240412233310.GF4163@brightrain.aerifal.cx>
[-- Attachment #1: Type: text/plain, Size: 1152 bytes --]
Good catch on the overflow. Yes, that patch looks correct to me and I
confirmed it fixes the issue on ARMv7.
> On Apr 12, 2024, at 4:33 PM, Rich Felker <dalias@libc.org> wrote:
>
> On Fri, Apr 12, 2024 at 03:57:28PM -0400, Rich Felker wrote:
>> On Thu, Apr 11, 2024 at 06:17:25PM -0700, Peter Ammon wrote:
>>> if (p>=0 && p<(LDBL_MANT_DIG-1+3)/4) {
>>> int re = LDBL_MANT_DIG-1-(p*4);
>>> long double round = 1ULL<<re;
>>
>> This expression overflows. re can be as large as 108 but 1ULL has
>> 64-bit type.
>>
>> There's probably some reasonable way to write it that works for
>> reasonable sizes of long double (I think it's safe to assume IEEE quad
>> is the max that will ever be supported), but I presume I wrote it with
>> the original inefficient loop to be fully general to arbitrary
>> precision.
>>
>> It could just be written to use scalbn, I think. At the time I
>> probably was trying to avoid dependency on a libm that could have been
>> separate from libc (bad historical thing). IIRC there was a time when
>> frexp was not used either.
>
> Does the attached look ok?
>
> Rich
> <pct_a.diff>
[-- Attachment #2: Type: text/html, Size: 4727 bytes --]
prev parent reply other threads:[~2024-04-13 16:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-12 1:17 Peter Ammon
2024-04-12 2:34 ` Rich Felker
2024-04-12 19:57 ` Rich Felker
2024-04-12 23:33 ` Rich Felker
2024-04-13 16:00 ` Peter Ammon [this message]
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=07FBEE99-778B-4A8C-B968-077B4515E000@ridiculousfish.com \
--to=corydoras@ridiculousfish.com \
--cc=musl@lists.openwall.com \
/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.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
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 NNTP newsgroup(s).