5 ms·
I have never seen anyone argue for a ‘switch’ version. switch (v) { case: 0,2,4,8,…: return EVEN; case: 1,3,5,7,…: return ODD;
by jagged-chisel 10mo ago
I have never seen anyone argue for a ‘switch’ version.
switch (v) {
case: 0,2,4,8,…:
return EVEN;
case: 1,3,5,7,…:
return ODD;
default:
return IDK;
}
Slightly less code to generate.
- willguest 10mo agoyou forgot the logic to strip the final digit and assign it to v. processing the whole number is absurd
- pkaeding 10mo agoI think the idea is to fill in the ellipses with even/odd numbers, up to 4B. You know, to save the performance cost of processing the input as a string, and chomping off all but the last character.
- 71bw 10mo agoLook at Mr. Rocket Scientist over here...
- mgaunard 10mo agoConverting to decimal is just as absurd. All you need is the final binary digit, which incidentally is the most optimal codegen, `v & 1`.