Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!crdgw1!underdog!volpe From: volpe@underdog.crd.ge.com (Christopher R Volpe) Newsgroups: comp.lang.c Subject: Re: Assinging values to type float Message-ID: <11394@crdgw1.crd.ge.com> Date: 28 Aug 90 21:21:10 GMT References: <90240.003415RHMCSUPV@MIAMIU.BITNET> <667.26da7736@iccgcc.decnet.ab.com> Sender: news@crdgw1.crd.ge.com Reply-To: volpe@underdog.crd.ge.com (Christopher R Volpe) Lines: 38 In article <667.26da7736@iccgcc.decnet.ab.com>, browns@iccgcc.decnet.ab.com (Stan Brown, Oak Road Systems) writes: |>In article <90240.003415RHMCSUPV@MIAMIU.BITNET>, RHMCSUPV@MIAMIU.BITNET (Douglas M. MacFarlane) writes: |>> |>> float fValue ; /* define fValue as a floating point variable */ |>> |>> other lines |>> |>> fValue = 35 ; /* produces a Data Conversion warning at compile time */ |>> |>> |>> Whasss Happening ???? |>> |>> Douglas M. MacFarlane |>> rhmcsupv@miamiu.acs.muohio.edu |> |> |>From the Microsoft C 5.1 user's guide, page 275: |> |>C4051 data conversion |> Two data items in an expression had different types, causing |> the type of one item to be converted. |> |>"fValue" is a float. "35" is an int. The compiler converted an int to a |>float for you. If you wanted a float, it thinks, you'd have written 35.0. |>(Of course 35.0 is actually a double, as are all floating-point constants, |>but that's another story.) 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"? ================== Chris Volpe G.E. Corporate R&D volpecr@crd.ge.com