andioop@programming.dev to Programming Horror@programming.devEnglish · edit-21 year agoGod I wish there was an easier way to do thisprogramming.devimagemessage-square45fedilinkarrow-up188arrow-down110
arrow-up178arrow-down1imageGod I wish there was an easier way to do thisprogramming.devandioop@programming.dev to Programming Horror@programming.devEnglish · edit-21 year agomessage-square45fedilink
minus-squareMac@programming.devlinkfedilinkarrow-up7·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-squareNullPointer@programming.devlinkfedilinkarrow-up4·1 year agohere is somewhat less: return (number % 2) == 0;
minus-squarehuf [he/him]@hexbear.netlinkfedilinkEnglisharrow-up2·1 year agojust check the last bit jesus christ, what is it with these expensive modulo operations?! return !(n&1);
minus-squareperviouslyiner@lemm.eelinkfedilinkEnglisharrow-up2·1 year agoare the negative numbers all even?
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;
just check the last bit jesus christ, what is it with these expensive modulo operations?!
return !(n&1);
return !(number & 1);
are the negative numbers all even?
Yes