@[email protected] to Programming [email protected]English • edit-21 year agoGod I wish there was an easier way to do thisprogramming.devimagemessage-square42fedilinkarrow-up1192arrow-down121
arrow-up1171arrow-down1imageGod I wish there was an easier way to do thisprogramming.dev@[email protected] to Programming [email protected]English • edit-21 year agomessage-square42fedilink
minus-squareMaclinkfedilink16•edit-21 year agowho needs modulo when you can get less characters out of while (number > 1) { number -= 2; } return number; very efficient edit: or theres the trusty iseven api
minus-squareMuchPineappleslink8•edit-21 year agoThis is the way. Modulo takes too long to compute, bitwise compare should be a lot faster. return !(number & 0x1);
minus-squarerecursive_recursion [they/them]linkfedilinkEnglish5•edit-21 year agooh shit yo this comment chain is pretty awesome, I learned a lot from this thanks!
who needs modulo when you can get less characters out of
while (number > 1) { number -= 2; } return number;
very efficient
edit: or theres the trusty iseven api
here is somewhat less:
return (number % 2) == 0;
return !(number & 1);
This is the way. Modulo takes too long to compute, bitwise compare should be a lot faster.
return !(number & 0x1);
oh shit yo
this comment chain is pretty awesome, I learned a lot from this thanks!
are the negative numbers all even?