Home > Back-end >  My understanding of the random number increased
My understanding of the random number increased

Time:06-04

(int) (15.0 * rand ()/(1.0) RAND_MAX +) in the end: 1, 2, 3... 14

The rand () range is [0, RAND_MAX]
15.0 * rand () to get a floating point number,
Is 15 times [0, RAND_MAX], [0.0, 15.0 * RAND_MAX],
15.0 * rand ()/RAND_MAX is [0.0, 15.0]
15.0 * rand ()/(RAND_MAX + 1.0) [0.0, 15.0)
(int) (15.0 * rand ()/(1.0) RAND_MAX +) 0... 14


CodePudding user response:

I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10581430.html
I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10768339.html
  • Related