def calc_bits_to_align(bits):
    """Calculates the number of bits needed to align byte.

    :param bits: Number of bits
    :type bits: int
    :return: Number of bits needed to align byte
    :rtype: int
    """
    remainder = bits % 8
    if remainder > 0:
        return 8 - remainder
    return 0
