/usr/games/random bug?

James R. Van Artsalen james at jrv.org
Mon Dec 20 18:20:39 PST 2004


Brooks Davis wrote:

>>       .p2align 3
>>.LC17:
>>       .long   0
>>       .long   1006632960
>>
>>       call    random
>>       cvtsi2sdq       %rax, %xmm0
>>       mulsd   24(%rsp), %xmm0
>>       mulsd   .LC17(%rip), %xmm0
>>       cvttsd2si       %xmm0, %eax
>>       jmp     .L1
>>    
>>
>I believe the code is bogus.  The code says, compute a long
>(denom*random) then divide it by the largest possiable value you can
>store in a long.
>

denom is a double.  random() is converted to a double and the arithmetic 
is floating point.

It does seem odd that it works on i386 FreeBSD-4


More information about the freebsd-amd64 mailing list