poppar

poppar(v) == popcnt(v) % 2

  1. bool poppar(uint v)
  2. bool poppar(ulong v)
    bool
    poppar
    (
    ulong v
    )

Examples

1 import std.random;
2 foreach (i; 0..100) {
3     uint v = uniform!"[]"(0U, uint.max);
4     assert(poppar(v) == popcnt(v) % 2);
5 }
6 foreach (i; 0..100) {
7     ulong v = uniform!"[]"(0UL, ulong.max);
8     assert(poppar(v) == popcnt(v) % 2);
9 }

Meta