def set_bit(value, index, high=True):
    """Set the index:th bit of value.

    Args:
        value (int): Number that will have bit modified.
        index (int): Index of bit to set.
        high (bool): True (default) = set bit high, False = set bit low
    """
    mask = 1 << index
    value &= ~mask
    if high:
        value |= mask
    return value