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

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

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



RJ
RJ

Antworte allen(2)
数据分析师

老师,随机问题用floor方法,永远取不要最大值,为什么不用round?-PHP中文网问答-老师,随机问题用floor方法,永远取不要最大值,为什么不用round?-PHP中文网问答

围观一下哦,学习一下。

阿神

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

Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!