rmcilroy / octane-benchmark

Automatically exported from code.google.com/p/octane-benchmark
0 stars 0 forks source link

The deterministic random number generation function does not produce values on the full 32-bit signed possible range #18

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Although the seed might take values between 0 and 0xffff ffff, the function 
returns values between 0 and 0xfff ffff / 0x1000 0000: 

base.js
l 130: return (seed & 0xfffffff) / 0x10000000;

To fully exploit the range of all possible numbers on 32-bit signed, it should 
do instead:

l 130: return (seed & 0x7fffffff) / 0x80000000;

I guess the original intend was to remove the sign bit and compute the ratio 
with a number immediately greater than the maximum positive value on 32-bit 
signed (0x80000000).

It means that the current random number generator won't produce some values 
between 0xfff ffff (7 'f') / 0x1000 0000 and 1.

I believe it is not such a big deal for current benchmarks and I can't think of 
a case where that would matter, but maybe it could be an issue someday?

Original issue reported on code.google.com by erick.la...@gmail.com on 15 Apr 2014 at 11:55

GoogleCodeExporter commented 9 years ago
What this basically means is that we produce only 28 random bits, with your 
change it would be 31, with 
https://code.google.com/p/v8/source/browse/branches/bleeding_edge/src/math.js#18
0 it would be 32. Of course the RNG will still not produce most numbers in 
[0..1), because the IEEE 754 mantissa has 52 bits, while we produce 32. So 
changing this will make things marginally better, but I think it's not worth 
the trouble for the benchmark suite. Furthermore, any change here would mean 
that we would not be able to compare benchmark numbers before and after this 
change anymore, which would be unfortunate.

If somebody fundamentally disagrees, feel free to re-open this issue, but 
otherwise I think we won't take any action here.

Original comment by svenpanne@chromium.org on 16 Apr 2014 at 11:03