Class XNumber
- Namespace
- Prefrontal.Common.Extensions
- Assembly
- Prefrontal.Core.dll
Provides extension methods for numerical types.
public static class XNumber
- Inheritance
-
XNumber
- Inherited Members
Methods
OrAtLeast<T>(T, T)
Returns value if it is greater than lowerLimit,
otherwise returns lowerLimit.
This is a shorthand for Math.Max(value, lowerLimit).
public static T OrAtLeast<T>(this T value, T lowerLimit) where T : INumber<T>
Parameters
valueTThe value to compare.
lowerLimitTThe lower limit of the return value.
Returns
- T
The value or the lower limit.
Type Parameters
TThe type of the value.
Remarks
In case of floating-point values, if either parameter is NaN,
the result will be lowerLimit.
OrAtMost<T>(T, T)
Returns value if it is less than upperLimit,
otherwise returns upperLimit.
This is a shorthand for Math.Min(value, upperLimit).
public static T OrAtMost<T>(this T value, T upperLimit) where T : INumber<T>
Parameters
valueTThe value to compare.
upperLimitTThe upper limit of the return value.
Returns
- T
The value or the upper limit.
Type Parameters
TThe type of the value.
Remarks
In case of floating-point values, if either parameter is NaN,
the result will be upperLimit.