Wednesday, November 7, 2012

Get random Float value, between two Float value


If you want to get random Float value use this method

- (float)randomFloatBetween:(float)smallNumber andMax:(float)bigNumber {
    float diff = bigNumber - smallNumber;
    return (((float) (arc4random() % ((unsigned)RAND_MAX + 1)) / RAND_MAX) * diff) + smallNumber;
}

No comments:

Post a Comment

Add your comment