Date: Mon, 20 Dec 2004 19:13:49 -0600 From: "James R. Van Artsalen" <james@jrv.org> To: freebsd-amd64@freebsd.org Subject: /usr/games/random bug? Message-ID: <41C778CD.1080602@jrv.org>
next in thread | raw e-mail | index | archive | help
5-stable "/usr/games/random -e 99" seems to always return 0, which makes it very predictable. 5.2.1 does this too. But i386 4.x seems to work as expected (an exit value between 0 and 98 inclusive). The source code line in question is return (int)((denom * random()) / LONG_MAX); the assembler code is .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'm not familiar enough with IEEE fp rules or amd64 fp coding to say why this doesn't work, nor if this source code is even reasonable.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?41C778CD.1080602>