feat: Math.AbsMax & AbsMin
This commit is contained in:
parent
5826230e7a
commit
0725468f2c
|
@ -129,7 +129,13 @@ public static class Math
|
|||
/// <param name="x">The first number.</param>
|
||||
/// <param name="y">The second number.</param>
|
||||
/// <returns>The number whose absolute value is larger.</returns>
|
||||
public static float MaxMagnitude(float x, float y) => MathF.MaxMagnitude(x, y);
|
||||
public static T AbsMax<T>(T x, T y) where T : INumber<T>
|
||||
{
|
||||
T xAbs = Abs(x);
|
||||
T yAbs = Abs(y);
|
||||
|
||||
return (xAbs > yAbs) ? x : y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the smaller of two numbers.
|
||||
|
@ -146,7 +152,13 @@ public static class Math
|
|||
/// <param name="x">The first number.</param>
|
||||
/// <param name="y">The second number.</param>
|
||||
/// <returns>The number whose absolute value is smaller.</returns>
|
||||
public static float MinMagnitude(float x, float y) => MathF.MinMagnitude(x, y);
|
||||
public static T AbsMin<T>(T x, T y) where T : INumber<T>
|
||||
{
|
||||
T xAbs = Abs(x);
|
||||
T yAbs = Abs(y);
|
||||
|
||||
return (xAbs < yAbs) ? x : y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a specified number raised to the specified power.
|
||||
|
|
Loading…
Reference in New Issue