def round_updown_to_x(num_in, x, direction="up"):
    """
    Rounds a given value (num_in) to the nearest multiple of x, in a given
    direction (up or down)
    :param num_in: Input value
    :param x: Value to round to a multiple of
    :param direction: Round up or down. Default: 'up'
    :return: Rounded number
    """
    if direction == "down":
        num_out = int(num_in) - int(num_in) % int(x)
    else:
        num_out = num_in + (x - num_in) % int(x)
    return num_out