clamp

fun clamp(x: Double, lo: Double, hi: Double): Double

Clamps x to the range [lo, hi].

Return

x if it is within the range, otherwise lo or hi.

Parameters

x

The value to clamp.

lo

The lower bound.

hi

The upper bound.