首页 >社区问答列表 >老师,随机问题用floor方法,永远取不要最大值,为什么不用round?

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

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

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



  • 数据分析师
  • 数据分析师    2017-10-01 00:27:592楼

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

    围观一下哦,学习一下。

    +0添加回复

  • 回复