Skip to content

Instantly share code, notes, and snippets.

@J-Moravec
Created November 8, 2024 02:46
Show Gist options
  • Save J-Moravec/bfef7b1879dd4c6e5fe8f2171a170b2c to your computer and use it in GitHub Desktop.
Save J-Moravec/bfef7b1879dd4c6e5fe8f2171a170b2c to your computer and use it in GitHub Desktop.
Is odd: bitwise or modulo?
is_odd_bitwise = \(x) bitwAnd(x, 1L)
is_odd_mod = \(x) x %% 2L
s = sample(1:1e7)
bench::mark(is_odd_bitwise(s), is_odd_mod(s))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment