▲ 911 ▼ I wish (i.imgur.com) submitted 2 years ago by nave@lemmy.zip to c/lemmyshitpost@lemmy.world 187 comments fedilink hide all child comments
[–] Karyoplasma@discuss.tchncs.de 29 points 2 years ago (3 children) while (true){ if (number == 0) return true; if (number == 1) return false; number -= 2 } permalink fedilink source hideshow 6 child comments replies: [–] SamBBMe@lemmy.world 12 points 2 years ago return !(number % 2) permalink fedilink source parent [–] stevep@lemmy.world 2 points 2 years ago (1 child) Setting number to -1 might cause you to wait a while. permalink fedilink source parent hideshow 2 child comments replies: [–] Karyoplasma@discuss.tchncs.de 1 point 2 years ago* You know, shortly after posting this I did think about whether it's still working if I just pass the underflow that will happen at some point or if I have to fix something in that case (like subtract 1 after the underflow). I deemed it "too complicated" and would just issue a warning that my code is only tested on positive numbers, but I think it will still work. permalink fedilink source parent [+] SamBBMe@lemmy.world 1 point 2 years ago [deleted] permalink fedilink source parent
[–] stevep@lemmy.world 2 points 2 years ago (1 child) Setting number to -1 might cause you to wait a while. permalink fedilink source parent hideshow 2 child comments replies: [–] Karyoplasma@discuss.tchncs.de 1 point 2 years ago* You know, shortly after posting this I did think about whether it's still working if I just pass the underflow that will happen at some point or if I have to fix something in that case (like subtract 1 after the underflow). I deemed it "too complicated" and would just issue a warning that my code is only tested on positive numbers, but I think it will still work. permalink fedilink source parent
[–] Karyoplasma@discuss.tchncs.de 1 point 2 years ago* You know, shortly after posting this I did think about whether it's still working if I just pass the underflow that will happen at some point or if I have to fix something in that case (like subtract 1 after the underflow). I deemed it "too complicated" and would just issue a warning that my code is only tested on positive numbers, but I think it will still work. permalink fedilink source parent