Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming > #12217 > unrolled thread

Using mathematical functions to create random numbers fast

Started byKristjan Robam <he12457@hotmail.com>
First post2021-02-16 13:33 -0800
Last post2021-02-16 13:33 -0800
Articles 1 — 1 participant

Back to article view | Back to comp.programming


Contents

  Using mathematical functions to create random numbers fast Kristjan Robam <he12457@hotmail.com> - 2021-02-16 13:33 -0800

#12217 — Using mathematical functions to create random numbers fast

FromKristjan Robam <he12457@hotmail.com>
Date2021-02-16 13:33 -0800
SubjectUsing mathematical functions to create random numbers fast
Message-ID<ee23d1a3-ed2a-4033-bcdf-cfda78883157n@googlegroups.com>
1) milliseconds from date
2) function rfast()
var a001="";
var b001=0;
var e001=new Date().getMilliseconds();
var a1=0;
var a01="";
function rfast() {
if(b001<a001.length) {
var d001=a001.substr(b001,Math.min(a001.length-b001, 2));
b001=b001+Math.min(a001.length-b001, 2);
return d001;
} else {
if(a001.length==0) a1=e001;
else {
a1= a001.substr(b001-2, 2);
b001=0;
}
}
a1=Math.round(a1*100000000)/1000000000;
for(var i=0; i<9999; i++) {
var i01=i*0.01142626643966346+i*0.0260774037134+0.1325346234;
a1=a1*a1*0.02060875985444033;
if(a1<0.001) a1=a1+0.0433469234896;
if(a1>10000000) a1=a1*0.000000439873469234896;
var j=a1*0.0432697460960975875*i01;
j=Math.round(j*100000000)/100000000;
a01=a01+" "+j;
}
var aa001=a01;
aa001=aa001.replace(/\./g,'');
aa001=aa001.replace(/\+/g,'');
aa001=aa001.replace(/\s/g,'');
aa001=aa001.replace(/\-/g,'');
a001=aa001;
var a0001=aa001.substr(b001,Math.min(aa001.length-b001, 2));
b001=b001+Math.min(aa001.length-b001, 2);
return a0001;
}


NB! : It is not 100% without errors ......


Kristjan Robam 

[toc] | [standalone]


Back to top | Article view | comp.programming


csiph-web