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 -

c# - WPF+EF - The operation cannot be completed because the DbContext has been disposed -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -