You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't know if this is ever possible to reproduce with any (known) seed, but if the next 120 arc4 outputs are 0, followed by a value less than 16, d will overflow to Infinity, making all outputs regardless of value 0. This means that contrary to what the comment // randomness in every bit of the mantissa of the IEEE 754 value. says, it doesn't actually produce any values between 0 and 2^-964.
This can be fixed by changing d to the log_0.5 of the actual denominator and forcing d <= 1074. If this is going to be fixed, a better solution would be to just change the hardcoded constants and add new ones, but here is a quick fix I made.
varprng=function(){varn=arc4.g(chunks),// Start with a numerator n < 2 ^ 48d=Math.log2(startdenom),// and denominator d = 48.x=0;// and no 'extra last byte'.while(n<significance&&d<1074){// Fill up all significant digits byn=(n+x)*width;// shifting numerator andd+=Math.log2(width);// denominator and generating ax=arc4.g(1);// new least-significant-byte.}while(n>=overflow||d>1074){// To avoid rounding up, before addingn/=2;// last byte, shift everythingd-=1;// right using integer math untilx>>>=1;// we have exactly the desired bits.}return(n+x)*Math.pow(2,-d);// Form the number within [0, 1).};
This is not an issue anyone will ever encounter, but I just noticed this and wanted to comment on it :).
The text was updated successfully, but these errors were encountered:
I don't know if this is ever possible to reproduce with any (known) seed, but if the next 120 arc4 outputs are 0, followed by a value less than 16, d will overflow to Infinity, making all outputs regardless of value 0. This means that contrary to what the comment
// randomness in every bit of the mantissa of the IEEE 754 value.
says, it doesn't actually produce any values between 0 and 2^-964.This can be fixed by changing d to the log_0.5 of the actual denominator and forcing d <= 1074. If this is going to be fixed, a better solution would be to just change the hardcoded constants and add new ones, but here is a quick fix I made.
This is not an issue anyone will ever encounter, but I just noticed this and wanted to comment on it :).
The text was updated successfully, but these errors were encountered: