Assinging values to type float
Peter Holzer
hp at vmars.tuwien.ac.at
Wed Aug 29 21:31:43 AEST 1990
volpe at 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 at crd.ge.com
--
| _ | Peter J. Holzer | Think of it |
| |_|_) | Technische Universitaet Wien | as evolution |
| | | | hp at vmars.tuwien.ac.at | in action! |
| __/ | ...!uunet!mcsun!tuvie!vmars!hp | Tony Rand |
More information about the Comp.lang.c
mailing list