refactor: Math.AbsMax & AbsMin to Single Liners
This commit is contained in:
parent
0725468f2c
commit
1dc8f3d272
|
@ -129,13 +129,7 @@ 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 T AbsMax<T>(T x, T y) where T : INumber<T>
|
||||
{
|
||||
T xAbs = Abs(x);
|
||||
T yAbs = Abs(y);
|
||||
|
||||
return (xAbs > yAbs) ? x : y;
|
||||
}
|
||||
public static T AbsMax<T>(T x, T y) where T : INumber<T> => (Abs(x) > Abs(y)) ? x : y;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the smaller of two numbers.
|
||||
|
@ -152,13 +146,7 @@ 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 T AbsMin<T>(T x, T y) where T : INumber<T>
|
||||
{
|
||||
T xAbs = Abs(x);
|
||||
T yAbs = Abs(y);
|
||||
|
||||
return (xAbs < yAbs) ? x : y;
|
||||
}
|
||||
public static T AbsMin<T>(T x, T y) where T : INumber<T> => (Abs(x) < Abs(y)) ? x : y;
|
||||
|
||||
/// <summary>
|
||||
/// Returns a specified number raised to the specified power.
|
||||
|
|
Loading…
Reference in New Issue