首页 > 代码库 > iOS生成最大最小数之间随机数

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

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 theminvalue, you’ll get a floatbetweenminandmax. Viola?, job done! 


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