[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: math.random returning out of range values
- From: Rena <hyperhacker@...>
- Date: Tue, 6 Nov 2012 22:33:11 -0500
Just noticed on Lua 5.1, on a 32-bit machine, math.random(0,
0x7FFFFFFF) always returns a negative number:
> return math.random(0, 0x7FFFFFFF)
-1649760493
0x7FFFFFFE has no such issue. 0x80000000 and up give an error which is
a bit nonsensical, but I at least understand why:
> return math.random(0, 0x80000000)
stdin:1: bad argument #2 to 'random' (interval is empty)
--
Sent from my Game Boy.