public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Takashi Yano <takashi.yano@nifty.ne.jp>
To: newlib@sourceware.org
Subject: Re: [PATCH] ldtoa: Fix insufficient valid output digits for "%f" format.
Date: Fri, 26 Nov 2021 06:51:06 +0900	[thread overview]
Message-ID: <20211126065106.7f2591edd95b317583a964cc@nifty.ne.jp> (raw)
In-Reply-To: <YZ+ZHZ3jWNwNgePx@calimero.vinschen.de>

On Thu, 25 Nov 2021 15:09:33 +0100
Corinna Vinschen wrote:
> looks good, but I see a potential problem at one point:
> 
> On Nov 25 21:02, Takashi Yano wrote:
> > +   limit now, either ndec (<= NDEC) or NDEC_SML, depending on ndigits. */
> > +  int ndec;
> > +  if (mode == 3) /* %f */
> > +    {
> > +      int expon = (e[NE - 1] & 0x7fff) - (EXONE - 1); /* exponent part */
> > +      /* log2(10) approximately 485/146 */
> > +      ndec = expon * 146 / 485 + ndigits;
> 
> We have targets with sizeof(int) == 2.  If expon is any number up to
> 0x7fff, multiplying it with 146 will overflow.  Using __int32_t for
> expon should be safer.

Thanks for checking. I have just submitted v2 patch fixed.


-- 
Takashi Yano <takashi.yano@nifty.ne.jp>

      reply	other threads:[~2021-11-25 21:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-25 12:02 Takashi Yano
2021-11-25 14:09 ` Corinna Vinschen
2021-11-25 21:51   ` Takashi Yano [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=20211126065106.7f2591edd95b317583a964cc@nifty.ne.jp \
    --to=takashi.yano@nifty.ne.jp \
    --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).