Conversion of unsigned long to double

Chris Torek chris at mimsy.UUCP
Wed Apr 26 15:26:01 AEST 1989


In article <4612 at freja.diku.dk> njk at 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 at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.lang.c mailing list