Math.random()是令系统随机选取大于等于 0.0 且小于 1.0 的伪随机 double 值
函数返回 min(包含)~ max(不包含)之间的数字:
Math.floor(Math.random() * (max - min) ) + min;
函数返回 min(包含)~ max(包含)之间的数字
Math.floor(Math.random() * (max - min + 1) ) + min;
Math.random()是令系统随机选取大于等于 0.0 且小于 1.0 的伪随机 double 值
函数返回 min(包含)~ max(不包含)之间的数字:
Math.floor(Math.random() * (max - min) ) + min;
函数返回 min(包含)~ max(包含)之间的数字
Math.floor(Math.random() * (max - min + 1) ) + min;
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。