0

I've been trying to create program in Objective-C to return random value between specific minimum to maximum value.

I've searched online and found out people are using arc4random_uniform instead of random() or rand().

My question is how arc4random is different from random()? random() is definitely easier to remember and I get same result from both arc4random and random()

Thank You. Regards.

The1993
  • 592
  • 1
  • 7
  • 22
  • Unfortunately, that question does not quite satisfy me. It does not explain why and how is random() more predictable. – The1993 Dec 08 '14 at 03:44
  • See: http://stackoverflow.com/questions/17640624/arc4random-modulu-biased – Rob Napier Dec 08 '14 at 03:45
  • Not covered in other answers: think about whether you need better randomness or better performance in whatever your use case is. If you're, say, pulling random numbers several times per frame in a 60fps game just to make something look like it has realistic noise, `arc4random` is probably overkill. – rickster Dec 08 '14 at 06:55

0 Answers0