def unsigned_to_signed(value: int, size: int) ->int:
    """Converts the given value from its unsigned representation."""
    bit_size = 8 * size
    if value & 1 << bit_size - 1 != 0:
        value = -((1 << bit_size) - value)
    return value
