Path: utzoo!attcan!uunet!lll-winken!ames!ncar!tank!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c Subject: Re: Yet another pcc botch Message-ID: <15642@mimsy.UUCP> Date: 26 Jan 89 11:59:16 GMT References: <3310@cbnews.ATT.COM> <398@lakart.UUCP> <15620@mimsy.UUCP> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 22 In article <15620@mimsy.UUCP> I wrote: >Now, on a 3B, sizeof(int) > sizeof(short), so the answer depends >on whether your compiler implements classic C (65386.0) or pANS C >(-150.0). Oops: since sizeof(u_int)==4 and the range is 0..4294967295, a `classic C' compiler should produce 4294967146.0, not 65368.0. Thanks to Chris Aoki at Sun for pointing this out, and to Donn Seeley for further noting that some bits will then `rub off' if this is stored in a 32-bit float (so that you might get, say, 4294967040.0). (Donn also noticed a few typos: 65386 for 65368.) (In general, conversion from unsigned to float should be done using machine instructions of the form: convert signed to float if result < 0, add pow(2.0,32.0) e.g., on a vax, cvtlf r1,r0 jgeq 0f addf2 $0f4294967296.0,r0 0: ... ) -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris