Skip to main content
gamedev.net
🔒 Locked

function odd PLEASE!!!

Started by ubek666 3 replies 750+ views
Original Post
ubek666
ubek666
function looking for nieparzyste(odd numbers) If it will be this way: odd - this function which I am asking for for (int i = 0; i < 5; i++) { if (odd(i)) { //if even then break loops break; } } Very thx :)
Fruny
Fruny
i % 2 != 0
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
ubek666
ubek666
Very I am thanking you I was searching for it from a few days!!!
nife
nife
It's called modulus, so now you know ;-)
Killers don't end up in jailThey end up on a high-score!
xor
xor
odd(int i){  if(i&0x00000001)    return 0;  return 1;}


Note: this only works for -(2^32) <= i < (2^32)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.