MathNClampTNumeric Method

Returns value clamped to the inclusive range of bound1 and bound2.

Definition

Namespace: Jodosoft.Numerics
Assembly: Jodosoft.Numerics (in Jodosoft.Numerics.dll) Version: 2.0
public static TNumeric Clamp<TNumeric>(
	TNumeric x,
	TNumeric bound1,
	TNumeric bound2
)
where TNumeric : struct, new(), INumeric<TNumeric>

Parameters

x  TNumeric
 
bound1  TNumeric
The first bound of the result (may be the lower or upper bound).
bound2  TNumeric
The second bound of the result (may be the lower or upper bound).

Type Parameters

TNumeric

Return Value

TNumeric

value if bound1valuebound2.

-or-

bound1 if value < bound1.

-or-

bound2 if bound2 < value.

Remarks

This method may return NaN or Infinity. If NaN or Infinity cannot be represented by TNumeric, then this method may throw an ArithmeticException.

See Also