unsigned int assigned to double yields negative # ... Why?
Andrew Lue
andrew at nsc.nsc.com
Fri Mar 18 08:41:52 AEST 1988
Using various C compilers on VAX and Series 32000 based machines, I've
compiled the code below. I've gotten negative results instead of positive
results.
main()
{
unsigned int ui = 0xf0000000;
double d;
d = ui;
printf("%d\n");
}
The books by K&R and Harrison & Steele are unclear about how this conversion
should be applied. Does anyone know what the definitive conversion is?
Or is the decision left up to the compiler writers?
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Andrew H. Lue {decwrl|sun}!nsc!andrew
More information about the Comp.lang.c
mailing list