码迷,mamicode.com
首页 > 移动开发 > 详细

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

时间:2014-11-03 21:00:43      阅读:255      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   color   ar   os   sp   div   

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生成最大最小数之间随机数

标签:style   blog   http   io   color   ar   os   sp   div   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!