How to do xor(all bits from an Integer) efficiently?

For example, I want a function fun such that fun(0b0101) = xor(false, true, false, true)

A solution for Int64 would be sufficient. Solutions for short integers are more welcome.

f(x)=isodd(count_ones(x))

1 Like