我正在使用Math.floor((Math.random()* max-min)+ min)生成随机数, 此函数和random.nextDouble()有什么区别? 如何在Javascript中实现random.nextDouble?
答案 0 :(得分:0)
1。
var min = 99; var max = 101; Math.floor(Math.random() * (max - min)) + min; //random int from min to max (not including)
int(32位)[-2 ^(32-1),+ 2 ^(32-1)+1]([-2147483648,2147483647]);
双精度(64位)[-4.9e-324,1.7e + 308];
需要将int转换为double。