🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #49726

Re: strange output

#49726
From: Fergus Henderson
Date: Wed, 08 Dec 1993 18:13
27 lines
1326 bytes
richards@aaron.music.qc.edu (David Richards) writes:

>Hello folks - here's the problem:
>
>#include <stdio.h>
>main()
>{
>   long double ldb = 22343546554.435551;
>   printf("ldb = %f\n", ldb);
>}
>
>compile with: gcc -o longd longd.c
>BUT THE OUTPUT READS: ldb = 8.500005
>
>Forgive me if I'm dreaming but it looks like a bug to me!!
>Am I missing something that's so painfully obvious that an
>amoeba could see it?!#%@^??

Yes, even an ameoba could see the probe - if it used -Wall!
Remember, -Wall is your friend:

	foo.c:5: warning: double format, long double arg (arg 2)

You need to use %lf instead of %f.

-- 
Fergus Henderson                     fjh@munta.cs.mu.OZ.AU
Technical Details
Message-ID: <9334305.8663@mulga.cs.mu.OZ.AU>
Path: arc1-ca.pugleaf.net!gmd.de!Germany.EU.net!EU.net!uunet!munnari.oz.au!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!fjh
References: <9312071842.AA02949@aaron.music.qc.edu>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,6f7a036dfb120868
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1993-12-13 03:58:53 PST
Newsgroups: gnu.gcc.help
Path: arc1-ca.pugleaf.net!gmd.de!Germany.EU.net!EU.net!uunet!munnari.oz.au!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!fjh
From: fjh@munta.cs.mu.OZ.AU (Fergus Henderson)
Subject: Re: strange output
Message-ID: <9334305.8663@mulga.cs.mu.OZ.AU>
Sender: news@cs.mu.OZ.AU
Organization: Computer Science, University of Melbourne, Australia
References: <9312071842.AA02949@aaron.music.qc.edu>
Distribution: gnu
Date: Wed, 8 Dec 1993 18:13:28 GMT
Lines: 27