random even number in Objective-C? -


i know :

randnum = arc4random_uniform(n); 

will set randnum random number 0 n - 1.

however how can modify above statement random number 0 n - 1?

it faster using bitwise operator, clear lowest bit @gallymon said.

unsigned int evennumber = arc4random_uniform(n) & 0xfffffffe ;


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -