Path: utzoo!mnetor!uunet!vsi!sullivan From: sullivan@vsi.UUCP (Michael T Sullivan) Newsgroups: comp.lang.c Subject: Re: unsigned int assigned to double yields negative # ... Why? Message-ID: <414@vsi.UUCP> Date: 19 Mar 88 01:21:05 GMT References: <5020@nsc.nsc.com> Organization: V-Systems, Inc. -- Santa Ana, CA Lines: 30 Keywords: conversions Summary: Take charge In article <5020@nsc.nsc.com>, andrew@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@vsi.com