tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: mrand48 broken on 64-bit systems
On Oct 22, 2013, at 2:13 AM, Alan Barrett <apb%cequrux.com@localhost> wrote:
>> 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.
No, it's unsigned due to __rand48_seed being unsigned. (confirmed by
checking at the resultant code).
> I think it's much better to use explicit fixed-width types.
Well, it's an ancient interface. I had considered changing it
to use 64-bit types internally (at least for LP64) but given how
often it's used, I didn't think it was worth the effort.
Home |
Main Index |
Thread Index |
Old Index