Kasper,
For a pseudo-random number generator you can also use a linear
feedback shift register
(http://en.wikipedia.org/wiki/Linear_feedback_shift_register) which
simplifies the code significantly. The below code produces a 24-bit
sequence:
Random.prototype.nextInt = function Random_nextInt(max) {
var old_seed = this.seed_;
var new_seed;
if ((old_seed & 1) == 0) {
new_seed = old_seed >> 1;
} else {
new_seed = (old_seed >> 1) ^ 0xe10000;
}
this.seed_ = new_seed;
return new_seed % max;
}
More sequences are linked from the wiki page.
-Ivan
On Wed, Oct 1, 2008 at 23:26, <[EMAIL PROTECTED]> wrote:
>
> Reviewers: Erik Corry,
>
> Description:
> Removed the use of Math.random() and new Date() for building
> the RNG pool in the crypto benchmark.
>
> Please review this at http://codereview.chromium.org/6071
>
> Affected files:
> M benchmarks/README.txt
> M benchmarks/base.js
> M benchmarks/crypto.js
> M benchmarks/run.html
>
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---