Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 9 Feb 2003 03:36:58 +1100 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Eirik Nygaard <eirikn@bluezone.no>
Cc:        standards@FreeBSD.ORG
Subject:   Re: strtof()
Message-ID:  <20030209022751.Q19037-100000@gamplex.bde.org>
In-Reply-To: <20030208135921.GA72899@eirikn.net>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030209022751.Q19037-100000>