mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@aerifal.cx>
To: musl@lists.openwall.com
Subject: Re: Undefined behavior in atoi()
Date: Tue, 8 Nov 2011 09:12:16 -0500	[thread overview]
Message-ID: <20111108141216.GQ132@brightrain.aerifal.cx> (raw)
In-Reply-To: <CAOH62Jggcu2Ej9-9djYaF3NEqXMfujBoPdPZM8VHhbBj7V=Y+g@mail.gmail.com>

On Tue, Nov 08, 2011 at 06:43:45AM +0100, Pascal Cuoq wrote:
> On Tue, Nov 8, 2011 at 4:44 AM, Rich Felker <dalias@aerifal.cx> wrote:
> 
> > On Sun, Nov 06, 2011 at 11:28:41PM +0100, Pascal Cuoq wrote:
> >
> > > I was looking at implementations for strtod() (long story for another
> > time)
> >
> > It should be noted that the current implementation is not correct.
> > There's lots of loss-of-precision.
> >
> 
> So I have seen, but if it's possible to do better for the objectives of
> musl,
> I do not know how. David M. Gay's code is efficient but it's not portable,
> and the other implementation I found (provided as part of Tcl and Ruby
> for instance) is only to a few ULPs too.
> 
> I am going to write my own, with multi-precision integers (that I already
> rely on for other things). I am hoping that by letting ldexp take care
> of denormals and infinites, it will be simple.

I believe it's possible using a method similar to what's in
vfprintf.c, but in reverse. In principle this amounts to using
high-precision floats, but with only a couple operations permitted on
them and fixed-size buffers, the code simplifies down to a managable
level. Actually that's why mentioning it came to mind..

Rich


      reply	other threads:[~2011-11-08 14:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-06 14:24 Pascal Cuoq
2011-11-06 21:21 ` Rich Felker
2011-11-06 22:28   ` Pascal Cuoq
2011-11-08  3:44     ` Rich Felker
2011-11-08  5:43       ` Pascal Cuoq
2011-11-08 14:12         ` Rich Felker [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=20111108141216.GQ132@brightrain.aerifal.cx \
    --to=dalias@aerifal.cx \
    --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).