title: "interval is empty", Lua math.random isn't working for large numbers?
body: <p>I didn't know if this is a bug in Lua itself or if I was doing something wrong. I couldn't find anything about it anywhere. I am using Lua for Windows (Lua 5.1.4):</p>
  
  <pre><code>&gt;return math.random(0, 1000000000)
  1251258
  </code></pre>
  
  <p>This returns a random integer between 0 and 10000000000, as expected. This seems to work for all other values. But if I add a single 0:</p>
  
  <pre><code>&gt;return math.random(0, 10000000000)
  stdin:1: bad argument #2 to 'random' (interval is empty)
  </code></pre>
  
  <p>Any number higher than that does the same thing.</p>
  
  <p>I tried to figure out exactly how high a number has to be to cause this and found something even weirder:</p>
  
  <pre><code>&gt;return math.random(0, 2147483647)
  -75617745
  </code></pre>
  
  <p>If the value is 2147483647 then it gives me negative numbers. Any higher than that and it throws an error. Any lower than that and it works fine.</p>
  
  <p>That's <code>0b1111111111111111111111111111111</code> in binary, 31 binary digits exactly. I am not sure what that means though.</p>