Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!tank!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c Subject: Re: Conversion of unsigned long to double Message-ID: <17110@mimsy.UUCP> Date: 26 Apr 89 05:26:01 GMT References: <515@bsiao.UUCP> <4612@freja.diku.dk> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 24 In article <4612@freja.diku.dk> njk@freja.diku.dk (Niels J|rgen Kruse) writes: >Lest you should harbour any delusions that the Bsd 4.3 cc >handles unsigned arithmetic and conversions correctly in >general, try running this little program : > if ((unsigned)-1 < 1) printf ("*splat*\n"); > else printf ("correct.\n"); Fixed in 4.3-tahoe. (Donn uncommented a cast within PCC itself that had been disabled.) > printf ("Second test : the same value assigned to dblt[0] and dblt[1]\n"); > dblt[i] = ut[2]; > dblt[++i] = ut[2]; Oops! The compiler is using the subscript addressing modes (-40(fp)[r1]) for both the jbsc (to test and clear the sign bit) and the addd2 (to add 2^31); but the latter multiplies r1 by 8, not 4, so it adds to the wrong variable. Might be fixed in 4.4 :-) , -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris