always when I try to generate a random number with Int = arc4random % MAXNUM the length of the number is as long as the MAXNUM number length -1. So if I set arc4random % 1000000 the number is between 100000-999999. How can I get different numbers like 78, 476 or 4842? Here a sample:
int number = arc4random() % 1000000;
outputLabel.text = [NSString stringWithFormat:@"The Number is %d", number];
Thanks for your help and sorry for my bad English!
Update: Okay I just saw, that I dont get only 5-digit-numbers, but most of the time. Is there a way to get more often lower numbers or numbers with less digits?
If you want to get a random integer in the range x
to y
, you can do that by int randomNumber = (arc4random() % y) + x;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With