refactor: Math.AbsMax & AbsMin to Single Liners

This commit is contained in:
Syntriax 2024-02-01 13:01:35 +03:00
parent 0725468f2c
commit 1dc8f3d272
1 changed files with 2 additions and 14 deletions

View File

@ -129,13 +129,7 @@ public static class Math
/// <param name="x">The first number.</param> /// <param name="x">The first number.</param>
/// <param name="y">The second number.</param> /// <param name="y">The second number.</param>
/// <returns>The number whose absolute value is larger.</returns> /// <returns>The number whose absolute value is larger.</returns>
public static T AbsMax<T>(T x, T y) where T : INumber<T> public static T AbsMax<T>(T x, T y) where T : INumber<T> => (Abs(x) > Abs(y)) ? x : y;
{
T xAbs = Abs(x);
T yAbs = Abs(y);
return (xAbs > yAbs) ? x : y;
}
/// <summary> /// <summary>
/// Returns the smaller of two numbers. /// Returns the smaller of two numbers.
@ -152,13 +146,7 @@ public static class Math
/// <param name="x">The first number.</param> /// <param name="x">The first number.</param>
/// <param name="y">The second number.</param> /// <param name="y">The second number.</param>
/// <returns>The number whose absolute value is smaller.</returns> /// <returns>The number whose absolute value is smaller.</returns>
public static T AbsMin<T>(T x, T y) where T : INumber<T> public static T AbsMin<T>(T x, T y) where T : INumber<T> => (Abs(x) < Abs(y)) ? x : y;
{
T xAbs = Abs(x);
T yAbs = Abs(y);
return (xAbs < yAbs) ? x : y;
}
/// <summary> /// <summary>
/// Returns a specified number raised to the specified power. /// Returns a specified number raised to the specified power.