Comment on I wish
Pulsar@lemmy.world 11 months agorealpython.com/python-modulo-operator/#how-to-che…
I just wonder why module is the wrong solution.
Comment on I wish
Pulsar@lemmy.world 11 months agorealpython.com/python-modulo-operator/#how-to-che…
I just wonder why module is the wrong solution.
mellejwz@lemmy.world 11 months ago
Not neccessarily wrong, but you could also check the first bit. If it’s 1 the number is uneven, if it’s 0 the number is even. That seems to be more efficient.
ziviz@lemmy.sdf.org 11 months ago
Huh… That makes sense. Til. Ran some tests but speed is pretty similar. Only 4% faster using bitmath or 300 milliseconds difference after 10mil runs.
herrvogel@lemmy.world 11 months ago
Modern compilers and interpreters are smart enough to figure out what you’re trying to do and automatically do that for you.