tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: mrand48 broken on 64-bit systems



lrand/nand returns change to:

        return __rand48_seed[2] * 32768 + (__rand48_seed[1] >> 1);

And all casts go away.  the multiply promotes everything to unsigned int.

Here, I think the multiply will be performed using signed int (in the common case that int is larger than 16 bits), or signed long (in the case that both int and short are 16 bits). I can't see a case where unsigned int would be used, but I could easily be wrong -- this stuff is confusing.

I think it's much better to use explicit fixed-width types.

--apb (Alan Barrett)


Home | Main Index | Thread Index | Old Index