def bitcount(num: int) ->int:
    """
    Count the number of bits in a numeric (integer or long) value. This
    method is adapted from the Hamming Weight algorithm, described (among
    other places) at http://en.wikipedia.org/wiki/Hamming_weight

    Works for up to 64 bits.

    **Parameters**

    - `num` (`int`): The numeric value

    **Returns**:

    The number of 1 bits in the binary representation of `num`
    """
    num = num - (num >> 1 & 6148914691236517205)
    num = (num & 3689348814741910323) + (num >> 2 & 3689348814741910323)
    num = num + (num >> 4) & 1085102592571150095
    return int(num * 72340172838076673 >> 56)
