unsigned int assigned to double yields negative # ... Why?
Michael T Sullivan
sullivan at vsi.UUCP
Sat Mar 19 11:21:05 AEST 1988
In article <5020 at nsc.nsc.com>, andrew at nsc.nsc.com (Andrew Lue) writes:
> {
> 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?
Why leave the decision up to the compiler writers? Cast ui:
d = (double)ui;
Don't rely on what you think may happen if the compiler happens to be
what you expect it to be.
good
food
yum
yum
yum
--
Michael Sullivan {uunet|attmail}!vsi!sullivan
{ucbvax|ihnp4|sun}!amdcad!uport!vsi!sullivan
HE V MTL sullivan at vsi.com
More information about the Comp.lang.c
mailing list