From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/524 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: Undefined behavior in atoi() Date: Tue, 8 Nov 2011 09:12:16 -0500 Message-ID: <20111108141216.GQ132@brightrain.aerifal.cx> References: <20111106212145.GO132@brightrain.aerifal.cx> <20111108034404.GP132@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1320762238 19425 80.91.229.12 (8 Nov 2011 14:23:58 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 8 Nov 2011 14:23:58 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-525-gllmg-musl=m.gmane.org@lists.openwall.com Tue Nov 08 15:23:53 2011 Return-path: Envelope-to: gllmg-musl@lo.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by lo.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1RNmae-000808-1X for gllmg-musl@lo.gmane.org; Tue, 08 Nov 2011 15:23:52 +0100 Original-Received: (qmail 9933 invoked by uid 550); 8 Nov 2011 14:23:51 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 9922 invoked from network); 8 Nov 2011 14:23:50 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:524 Archived-At: On Tue, Nov 08, 2011 at 06:43:45AM +0100, Pascal Cuoq wrote: > On Tue, Nov 8, 2011 at 4:44 AM, Rich Felker 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