Elementary.Clamp Method
Clips a number so that it is within the specified interval.
Definition
Namespace: Numerics.NET
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 9.0.3
C#
If x is less than or equal to lowerBound, then lowerBound; otherwise, if x is greater than or equal to upperBound, then upperBound; otherwise, x.
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 9.0.3
public static double Clamp(
double x,
double lowerBound,
double upperBound
)
Parameters
- x Double
- A real number.
- lowerBound Double
- The lower bound of the interval.
- upperBound Double
- The upper bound of the interval.
Return Value
DoubleIf x is less than or equal to lowerBound, then lowerBound; otherwise, if x is greater than or equal to upperBound, then upperBound; otherwise, x.