🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #50093

Re: what format to use for a double?

#50093
From: Lawrence Kirby
Date: Mon, 22 Nov 1993 19:29
28 lines
1889 bytes
In article <KEVINS.93Nov22093828@aragorn.ori.org> kevins@aragorn.ori.org writes:

>
>
>(I am posting this here as gcc is the only compiler that gives
> me this warning).
>
>Since "way back when" I have been using "%lf" as the format to
>print doubles.  Gcc always gives me the Warning "use of 'l' lenth
>character with 'f' type character."  I like to compile without
>any warnings, tell me how to disable this warning or what I should
>use instead of "%lf".

%f is the format specifier for double in printf (scanf is different). In
pre-ANSI C floats were always promoted to doubles when passed as function
arguments. In ANSI the promotion occurs only in old style (unprototyped)
or variable argument functions. printf is variable argument so it is
impossible to pass a float argument to it (at least not without some
unpleasant kludge like wrapping it up in a struct). In ANSI %lf
is undefined in printf.

In scanf pointers to variables are passed so float and double are distinct
and 'l' must be used in the format string to tell them apart.

-----------------------------------------
Lawrence Kirby | fred@genesis.demon.co.uk
Wilts, England | 70734.126@compuserve.com
-----------------------------------------
Technical Details
Message-ID: <753996547snz@genesis.demon.co.uk>
Path: arc1-ca.pugleaf.net!gmd.de!xlink.net!howland.reston.ans.net!pipex!uknet!demon!genesis.demon.co.uk!fred
References: <KEVINS.93Nov22093828@aragorn.ori.org>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,9c3f95dacf08ca9c
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1993-11-22 12:27:40 PST
Newsgroups: gnu.gcc.help
From: fred@genesis.demon.co.uk (Lawrence Kirby)
Path: arc1-ca.pugleaf.net!gmd.de!xlink.net!howland.reston.ans.net!pipex!uknet!demon!genesis.demon.co.uk!fred
Subject: Re: what format to use for a double? 
Distribution: world
References: <KEVINS.93Nov22093828@aragorn.ori.org>
Organization: none
X-Newsreader: Simple NEWS 2.0 (ka9q DIS 1.24)
Lines: 28
Date: Mon, 22 Nov 1993 19:29:07 +0000
Message-ID: <753996547snz@genesis.demon.co.uk>
Sender: usenet@demon.co.uk