from typing import Union


def clamp(x: Union[int, float], min_: Union[int, float], max_: Union[int, float]) -> Union[int, float]:
    """Clamp value between min and max."""
    return max(min_, min(x, max_))