[Webkit-unassigned] [Bug 98586] Extend random precision to 53bits

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Nov 27 06:34:20 PST 2012


https://bugs.webkit.org/show_bug.cgi?id=98586





--- Comment #23 from Yusuke Suzuki <utatane.tea at gmail.com>  2012-11-27 06:36:31 PST ---
(In reply to comment #22)

Thanks for your review.

> (From update of attachment 167484 [details])
> The more i look at this the less happy i am.  In principle I am in favour of having more random bits in the double, but the reality is that this method of getting that randomness produces a result where the low 32 bits will be extremely highly correlated with the high 21 bits.
> 
> I'd almost be tempted to pull double get() out of WeakRandom, and have a WeakRandomDouble class that has two separately initialized WeakRandom members, and use those two separate generators for the double.  This will remove the interdependency between the two.  As it is you've halved the period of the generator (something i may look at entirely independently later anyway), and you have not really gained an increase in the randomness of the low bits.

Right, thanks.
So I'll create new class WeakDoubleRandom and add it to JSGlobalObject members.
WeakDoubleRandom has 2 WeakRandom object and generates random double number by using them.

JSGlobalObject::weakRandomInteger needs uint32_t random value. But I think it is better to generate uint32_t random value by WeakRandom object instead of generating by WeakDoubleRandom object.

If generate 32bit value by WeakDoubleRandom, we can take 3 ways,
1:
generate 32bit value by using one WeakRandom object and return it. Another WeakRandom object is not used.

2:
generate 32bit value by using one WeakRandom object and return it. Another WeakRandom object is used, but value is discarded.

3:
generate two 32bit values by using two WeakRandom objects and discard 16bit and combine them to 32bit.

I think 1 is not good for WeakDoubleRandom's randomness and 2 and 3 are not good for weakRandomInteger performance.
So I suggest adding WeakDoubleRandom to JSGlobalObject in order to generate double numbers and leaving JSGlobalObject's WeakRandom object for 32bit random numbers.

I'll create revised patch soon.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list