@[email protected] to Lemmy [email protected]English • 2 years agoI wishi.imgur.comimagemessage-square171fedilinkarrow-up1930
arrow-up1930imageI wishi.imgur.com@[email protected] to Lemmy [email protected]English • 2 years agomessage-square171fedilink
minus-square@[email protected]linkfedilink16•2 years agostring taco = variable.ToString()[variable.ToString().Length - 1]; If (taco == “0” || taco == “2” || taco == “4” || taco == “6” || taco == “8”) return true; else return false; Im something of a coding master myself
minus-square@[email protected]linkfedilink3•2 years agoas division is complicated and expensive depending on the size of the numbers you’d usually receive as an input, this could be the most efficient solution. Certainly could have the best worst case if we imagine some 128bit shenanigans.
minus-square@[email protected]linkfedilink1•edit-22 years agoJust realised i fucked up and am checking them as strings instead of chars ¯\_(ツ)_/¯
string taco = variable.ToString()[variable.ToString().Length - 1];
If (taco == “0” || taco == “2” || taco == “4” || taco == “6” || taco == “8”)
return true;
else
return false;
Im something of a coding master myself
as division is complicated and expensive depending on the size of the numbers you’d usually receive as an input, this could be the most efficient solution. Certainly could have the best worst case if we imagine some 128bit shenanigans.
Just realised i fucked up and am checking them as strings instead of chars ¯\_(ツ)_/¯