Math<T>.Clamp Method

Returns a number constrained to be within the specified interval.

Definition

Namespace: Numerics.NET
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.7.0
C#
public static T Clamp(
	T value,
	T lowerBound,
	T upperBound
)

Parameters

value  T
The value to constrain.
lowerBound  T
The lower bound of the interval.
upperBound  T
The upper bound of the interval.

Return Value

T
value constrained to the specified interval.

Remarks

For floating-point values, a NaN value or NaN bound returns NaN.

Exceptions

ArgumentException

upperBound is less than lowerBound.

See Also