Bug converting unsigned to double in BSD 4.[23]

Kenneth R. Ballou ballou at brahms
Sat Nov 8 16:55:37 AEST 1986


I recently had occasion to perform this experiment:

% cat bug.c
main ()
{
  printf ("%u\n", ~ ((unsigned) 0));
  printf ("%lf\n", (double) (~ ((unsigned) 0)));
  printf ("%lf\n", 4294967295.0); /* surely double is large enough for this? */
}
% bug
4294967295
-1.000000
4294967295.000000

The results were the same on BSD 4.2 and BSD 4.3.  Of course, the question
is, did I miss something?  (I don't believe so.)

--------
Kenneth R. Ballou		...!ucbvax!cartan!brahms!ballou
Dept. of Mathematics
University of California
Berkeley, California  94720



More information about the Comp.lang.c mailing list