andioop@programming.dev to Programming Horror@programming.devEnglish · edit-2il y a 2 ansGod I wish there was an easier way to do thisprogramming.devimagemessage-square6linkfedilinkarrow-up12arrow-down10
arrow-up12arrow-down1imageGod I wish there was an easier way to do thisprogramming.devandioop@programming.dev to Programming Horror@programming.devEnglish · edit-2il y a 2 ansmessage-square6linkfedilink
minus-squareNullPointer@programming.devlinkfedilinkarrow-up0·il y a 2 anshere is somewhat less: return (number % 2) == 0;
minus-squareMuchPineapples@lemmy.worldlinkfedilinkarrow-up1·edit-2il y a 2 ansThis is the way. Modulo takes too long to compute, bitwise compare should be a lot faster. return !(number & 0x1);
minus-squarerecursive_recursion [they/them]@programming.devlinkfedilinkEnglisharrow-up1·edit-2il y a 2 ansoh shit yo this comment chain is pretty awesome, I learned a lot from this thanks!
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!