From owner-freebsd-standards Sat Feb 8 8:37:21 2003 Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8CA1C37B405 for ; Sat, 8 Feb 2003 08:37:20 -0800 (PST) Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id D91CA43FAF for ; Sat, 8 Feb 2003 08:37:18 -0800 (PST) (envelope-from bde@zeta.org.au) Received: from katana.zip.com.au (katana.zip.com.au [61.8.7.246]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id DAA12442; Sun, 9 Feb 2003 03:36:53 +1100 Date: Sun, 9 Feb 2003 03:36:58 +1100 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Eirik Nygaard Cc: standards@FreeBSD.ORG Subject: Re: strtof() In-Reply-To: <20030208135921.GA72899@eirikn.net> Message-ID: <20030209022751.Q19037-100000@gamplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sat, 8 Feb 2003, Eirik Nygaard wrote: > I tave made a strtof(3) function. > Attached is the function, a small test program and the man page. > I will also start on the strtold(3) now. This seems to be too simple to be correct. strtod() takes about 600 lines to do perfect (?) rounding, etc. Getting the last bit right is difficult. strtof() is already implemented by the same author as strtod(). See http://netlib.bell-labs.com/netlib/fp/index.html (file gdtoa.tar. See also dtoa.c for an up to date version of FreeBSD's strtod.c that has not been BSDified). Unfortunately, these files don't seem to be actively maintained (they haven't changed since I fetched them more than a year ago), and gdtoa seems to be missing any significant support for long doubles, and the differences between dtoa.c and FreeBSD's strtod.c are obfuscated by style "fixes" in the latter. I'm not sure of the state of support for C99 features like hex constants in dtoa.c. strtod.c seems to be missing even support for "INF" and "NAN" (we only changed the scanf family to support the C99 spelling of these). The scanf() family just uses strtod() to read floats. I think this sometimes gives rounding errors too (due to double rounding). Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message