I don't think get_rand_uniform()
does what you think it does. It probably looks like this:
float get_rand_uniform(void);
Or maybe double
. The point is, it returns a random decimal number between 0 and 1. So this:
get_rand_uniform() > 0.5
Is a check to see if that number is closer to 1 or 0. And this:
x ? y : z
Is the ternary conditional operator, which serves the same function as this:
if(x) { y } else { z }
Except that the ternary operator is an expression. So all of this:
get_rand_uniform() > 0.5 ? 1 : 0
Is basically rounding the random floating point number to 1 or 0, and this:
b = get_rand_uniform() > 0.5 ? 1 : 0;
Assigns that randomly picked 1 or 0 to b
. I believe the parenthesis are unnecessary here, but if you like them, go for it.