Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!snorkelwacker!bloom-beacon!eru!luth!sunic!mcsun!tuvie!vmars!hp From: hp@vmars.tuwien.ac.at (Peter Holzer) Newsgroups: comp.lang.c Subject: Re: Assinging values to type float Message-ID: <1778@tuvie> Date: 29 Aug 90 11:31:43 GMT References: <90240.003415RHMCSUPV@MIAMIU.BITNET> <667.26da7736@iccgcc.decnet.ab.com> <11394@crdgw1.crd.ge.com> Sender: news@tuvie Lines: 46 volpe@underdog.crd.ge.com (Christopher R Volpe) writes: >Ok, so which is it? Is the compiler complaining about the int-to-double >conversion for not writing 35.0? Or is it complaining about the >double-to-float conversion resulting in possible loss of precision? >Does the warning go away if you write "fValue=35.0;" or do you >need to write "fValue = (float) 35.0"? It complains about the double-to-float conversion. Here is a program that shows the not quite consequent behaviour of MSC: int main () { char c; int i; long l; float f; double d; c = 0; i = c; l = i; f = l; /* warning */ d = f; f = d; /* warning */ l = f; /* warning */ i = l; /* warning */ c = i; /* warning */ c = c; f = f; c = ! c; /* warning */ f = f + 1.0; /* Why doesn't it warn about this one ? * f + 1.0 is of type double. */ return 0; } >================== >Chris Volpe >G.E. Corporate R&D >volpecr@crd.ge.com -- | _ | Peter J. Holzer | Think of it | | |_|_) | Technische Universitaet Wien | as evolution | | | | | hp@vmars.tuwien.ac.at | in action! | | __/ | ...!uunet!mcsun!tuvie!vmars!hp | Tony Rand |