for an in I'm doing this:
int randomRange(int min, int max) {
int range = max - min;
if (range == 0) return min;
return (arc4random() % range) + min;
}
but how can I do this with a float?
+(float) randFloatBetween:(float)low and:(float)high
{
float diff = high - low;
return (((float) rand() / RAND_MAX) * diff) + low;
}
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