[net.lang.c] Using SCANF with DOUBLE precisi

karl@haddock (09/30/86)

orion!vaughan writes:
>After having my code bomb several times (unfortunately, I was not as lucky
>as you - instead of zeroes, I got core dumps), I discovered this ...

That's unlucky?  I'd rather get a core dump (which tends to point right at
the error) than the wrong answer (which may not become visible for a while).

Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint

karl@haddock (09/30/86)

ucsfcgl!kneller (Don Kneller) writes:
>In article <22@orion.UUCP> vaughan@orion.UUCP (Robert Vaughan) writes:
>>scanf("%lf",&foo);
>Except, of course, in the infinite wisdom of Silicon Graphics whose
>floats and doubles are the same size so one must use %f for both.  The
>"justification" is that they have yet another floating point type called
>long float with gets the %lf format.  It's painfully nonportable.  Sigh.

Then it isn't a C compiler and/or library.

Do you really mean "long float"?  In K&R that's a synonym for "double"; ANSI
removed this and added "long double" for which the format is "%Lf" (note
uppercase L).  The elegant solution would've been "short float" (formerly
"float"), format "%hf"; "float" (formerly double), format "%f"; and "long
float" (what ANSI calls "long double"), format "%lf", but elegance must defer
to compatibility.  Sigh.

Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint