Plauger & Brodie strtod description

Henry Spencer henry at utzoo.uucp
Sun Dec 31 09:29:37 AEST 1989


In article <1294 at quintus.UUCP> ok at quintus.UUCP (Richard A. O'Keefe) writes:
>The railroad diagram on page 163 of "Standard C" by Plauger & Brodie
>suggests that the string argument of strtod() must contain either a
>decimal point or an exponent, so that strtod("1234", (char**)NULL)
>must return 0.0 if called in the "C" locale.  This requirement matches
>the syntax of floating-point constants in C, but it is more restrictive
>than current versions of strtod(), which accept "1234".
>
>Q1: have Plauger & Brodie got it right?

P&B have goofed.  The description of strtod in the draft (well, the
Oct 88 draft, the one I've got) specifies that both decimal point and
exponent are optional, and explicitly assigns a meaning to the case
where neither is present.  For a guess, P&B copied the diagram from
the floating-point-constant one and overlooked the fine print.
-- 
1972: Saturn V #15 flight-ready|     Henry Spencer at U of Toronto Zoology
1989: birds nesting in engines | uunet!attcan!utzoo!henry henry at zoo.toronto.edu



More information about the Comp.std.c mailing list