Ad
  • Default User Avatar

    noooo, it's substraction, he wants to control the size of the sum..
    because when 3 int params are given, they must be in the correct range, so subtraction of any two of them will not cause a overflow.
    That should be some kind of tech worthy to remember.

  • Default User Avatar

    On my Core i7-4770K best performance is obviously using popcnt instruction, but this one is the next best. The most recommended solution with bitset has the worst performance so far.

    CPU clocks per item calculated:
    popcnt 2.7
    parallel bits counting 6.2
    lookup table 11.0
    std::bitset 16.3