老师,随机问题用floor方法,永远取不要最大值,为什么不用round?
RJ
RJ 2017-02-21 17:06:39
0
2
1190

Math.floor(Math.random()*(max-min)+min);//取不到max

Math.round(Math.random()*(max-min)+min);//可以取到min,也可以取到max,更合理一点



RJ
RJ

reply all(2)
数据分析师

Teacher, use the floor method for random questions and never take the maximum value. Why not use round? -PHP Chinese website Q&A-Teacher, use the floor method for random questions and never take the maximum value. Why not use round? -PHP Chinese website Q&A

Let’s take a look and learn.

阿神

嗯,是的,确实更合理点,你思考的很仔细

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template