Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!watnot!watmum!rmariani From: rmariani@watmum.UUCP Newsgroups: comp.sys.amiga Subject: Re: C-compilers for Amiga are Terrible (really Manx problem) Message-ID: <703@watmum.UUCP> Date: Mon, 1-Dec-86 00:15:44 EST Article-I.D.: watmum.703 Posted: Mon Dec 1 00:15:44 1986 Date-Received: Mon, 1-Dec-86 02:29:43 EST Reply-To: john13@garfield.UUCP (John Russell) Distribution: net Organization: U of Waterloo, Ontario Lines: 31 Keywords: %f printf floating point Summary: link with the math libraries In article <3061@garfield.UUCP> john13@garfield.UUCP (John Russell) writes: > >main() >{ float x=1; > printf("%f\n",x); } > >should work, right? Wrong! I tried this too and again it just printed the >letter f. So please, no flood of replies saying "force it to float with a >decimal point!". > >John Once you know all the details, this isn't really a problem, it's a feature. In the runtime libraries, a large amount of the code to do a printf is associated with printing formatted floating point numbers, however, this code is not always used (I hardly ever use floating point in my C programs for instance). Thus there are two versions of printf, one which doesn't have the floating point code in it (that's the one in c.lib and c32.lib) and one with the floating point code (m.lib and m32.lib (have I got those names right? Well the math libraries... whatever they're called). To get the version with the floating point in it, simply link with m.lib. Make sure that it is first in the list of libraries (or before c.lib anyway) otherwise you'll get the no %f version that's in the other library. Like I said this is a feature (It's documented! Read the manual! All of it! ) It makes many programs quite a bit smaller... -Rico