nave@lemmy.zip to Lemmy Shitpost@lemmy.worldEnglish · 11 months agoI wishi.imgur.comimagemessage-square150fedilinkarrow-up1707arrow-down116
arrow-up1691arrow-down1imageI wishi.imgur.comnave@lemmy.zip to Lemmy Shitpost@lemmy.worldEnglish · 11 months agomessage-square150fedilink
minus-square257m@sh.itjust.workslinkfedilinkarrow-up5·edit-211 months agonumber % 2 == 0 and (number & 0b1) == 0 Are the only sane ways to do this. No need to floor. Although If its C and you can’t modulo floats then (number/2 == floor(number/2))
minus-squarehomura1650@lemmy.worldlinkfedilinkarrow-up1·11 months agoIf you are using floats, you really do not want to have an isEven function …
number % 2 == 0 and (number & 0b1) == 0
Are the only sane ways to do this. No need to floor. Although If its C and you can’t modulo floats then (number/2 == floor(number/2))
If you are using floats, you really do not want to have an isEven function …