🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.c
Article #9428

Re: Using SCANF with DOUBLE precision variables...

#9428
From: Robert Vaughan
Date: Thu, 25 Sep 1986 21:57
18 lines
1360 bytes
>> I have been wanting to read in some real numbers, preferably thru SCANF
>> ...
>> declared as DOUBLE.  (...)

Well, go ahead! K&R, page 149 gives the key to reading in double precision
number using the scanf family:
	"the conversion characters e or f may be preceeded by l (letter l)
	 to indicate that .. a pointer to double rather than float is
	 expected"
The code would look like

double foo;

	scanf("%lf",&foo);

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 little
gem in K&R.
Technical Details
Message-ID: <22@orion.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!cbatt!ihnp4!qantel!lll-lcc!lll-crg!rutgers!topaz!ll-xn!mit-amt!mit-eddie!genrad!decvax!ucbvax!hplabs!sdcrdcf!trwrb!orion!vaughan
References: <3672@brl-smoke.ARPA> <108@nonvon.UUCP>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!cbatt!ihnp4!qantel!lll-lcc!lll-crg!rutgers!topaz!ll-xn!mit-amt!mit-eddie!genrad!decvax!ucbvax!hplabs!sdcrdcf!trwrb!orion!vaughan
From: vaughan@orion.UUCP (Robert Vaughan)
Newsgroups: net.lang.c
Subject: Re: Using SCANF with DOUBLE precision variables...
Message-ID: <22@orion.UUCP>
Date: Thu, 25-Sep-86 17:57:14 EDT
Article-I.D.: orion.22
Posted: Thu Sep 25 17:57:14 1986
Date-Received: Tue, 30-Sep-86 20:31:06 EDT
References: <3672@brl-smoke.ARPA> <108@nonvon.UUCP>
Organization: TRW Digital Development Laboratory, Manhattan Beach, CA
Lines: 18
Summary: scanf and fscanf have builtin capability to read double precision real numbers, as defined in K&R, page 149.