mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Pascal Cuoq <pascal.cuoq@gmail.com>
To: musl@lists.openwall.com
Subject: Re: Undefined behavior in atoi()
Date: Tue, 8 Nov 2011 06:43:45 +0100	[thread overview]
Message-ID: <CAOH62Jggcu2Ej9-9djYaF3NEqXMfujBoPdPZM8VHhbBj7V=Y+g@mail.gmail.com> (raw)
In-Reply-To: <20111108034404.GP132@brightrain.aerifal.cx>

[-- Attachment #1: Type: text/plain, Size: 1293 bytes --]

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.


> Glad to hear you found the code pleasant, at least that part. Some
> things (like floating point in vfprintf.c) are a bit ugly.. :)
>

I did look at the floating-point part in vfprintf.c, because of
the claim on musl's website that printing floating-point numbers
was correct. I have had trouble with floating-point
to decimal conversion too, but I cheated a little there by inventing
by own format:

http://blog.frama-c.com/index.php?post/2011/10/29/A-portable-OCaml-function-to-print-floats

Pascal

[-- Attachment #2: Type: text/html, Size: 2040 bytes --]

  reply	other threads:[~2011-11-08  5:43 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 [this message]
2011-11-08 14:12         ` Rich Felker

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='CAOH62Jggcu2Ej9-9djYaF3NEqXMfujBoPdPZM8VHhbBj7V=Y+g@mail.gmail.com' \
    --to=pascal.cuoq@gmail.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).