chris@mimsy.UUCP (Chris Torek) (03/20/88)
>In article <5020@nsc.nsc.com> andrew@nsc.nsc.com (Andrew Lue) writes: >>unsigned int ui = 0xf0000000; >>double d = ui; In article <414@vsi.UUCP> sullivan@vsi.UUCP (Michael T Sullivan) writes: >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. I expect the C compiler to implement the C language. If it does not, then perhaps nothing I add will help. And indeed, in this case, since the semantics of a cast are precisely the same as those of assignment to an unnamed temporary variable of the type of the cast, all this does is change a conversion from unsigned to double into a conversion from unsigned to double, and d = (double)ui; still fails under 4.1BSD. If you really need to work around the bug, try d = (int)ui < 0 ? (int)ui + 4.294967296e9 : (int)ui; Better yet, go fix the compiler. What, your vendor `forgot' to provide compiler sources? :-( -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris