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#
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

Double
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.

See Also