home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!haven.umd.edu!darwin.sura.net!jvnc.net!nuscc!eletanjm
- From: eletanjm@nuscc.nus.sg (TAN JIN MENG)
- Subject: Re: Help!!! Please Read this message!?!?!?!?!...
- Message-ID: <1992Sep9.043345.15040@nuscc.nus.sg>
- Organization: National University of Singapore
- References: <mcook.715979137@melkur.dev.cdx.mot.com>
- Date: Wed, 9 Sep 1992 04:33:45 GMT
- Lines: 32
-
- mcook@melkur.dev.cdx.mot.com (Michael Cook) writes:
- : eletanjm@nuscc.nus.sg (TAN JIN MENG) writes:
- :
- : >gmr6139@ultb.isc.rit.edu (G.M. Richard ) writes:
- : >: I can't get my compiler to do float-type variables.
- :
- : ...
- :
- : >: #define apples 4
- : >: #define oranges 3.6
- : >:
- : >: main()
- : >: {
- : >: printf("\nApples = %d\nOranges = %f", apples, oranges);
- : >: }
- :
- : >Your compiler can't know what orange is... So it assumes that its an
- : >int. That's why the wrong result. Alternatives ...
- :
- : What? Don't be silly... The compiler knows what orange is.
- :
- : Matt's problem is probably due to Turbo C trying to avoid linking against the
- : floating point library (so as to keep the program smaller). The compiler saw
- : no "float" or "double" declarations, and so it linked against the non-floating
- : point version of the standard library, and picked-up the non-floating point
- : version of printf, which probably doesn't understand %f.
-
-
- If the printf doesn't understand %f, it will print "%f" verbatim and not
- even attempt to interpret it.
-
- jin meng
-