首页 > 移动平台 > 详细

iOS生成最大最小数之间随机数

时间:2014-11-03 20:58:40      阅读:322      评论:0      收藏:0      [点我收藏+]

bubuko.com,布布扣

Note:Here’s how the above method works.arc4random() gives you a randominteger between 0 andARC4RANDOM_MAX. If you divide that number byARC4RANDOM_MAX, you get a float between 0 and 1.

If you multiply this value by the range of values (maxmin), you’ll get a floatbetween 0 and the range. If you add to that themin value, you’ll get a floatbetweenmin andmax. Viola?, job done! 


iOS生成最大最小数之间随机数

原文:http://blog.csdn.net/leochang130731/article/details/40746641

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!