返回列表

优秀的随机数生成函数

默认分类 2014/07/15 05:49

优秀的随机数生成函数:

<script type="text/javascript">
<!--
function doit(){ 
    //todo
    alert(rand(2))
}


// The Central Randomizer 1.3 (C) 1997 by Paul Houle (houle@msc.cornell.edu)
// See: http://www.msc.cornell.edu/~houle/javascript/randomizer.html
function rand(number) {
    return Math.ceil(rnd()*number);
};
rnd.today=new Date();
rnd.seed=rnd.today.getTime();
function rnd() {
    rnd.seed = (rnd.seed*9301+49297) % 233280;
    return rnd.seed/(233280.0);
};
// end central randomizer. -->

//-->
< /script>