function creatRandomNum(n){ var Random = 0; RandomCeil = Math.ceil(Math.random()*Math.pow(10,n)); RandomVar = RandomCeil / Math.pow(10,n); //RandomVar为RandomCeil对应的正整数 //n为指定的位数 return {"RandomCeil":RandomCeil,"RandomVar":RandomVar}; }
原文:http://www.cnblogs.com/hanbingljw/p/3997914.html