mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-14 14:24:10 +02:00
Generalized min/max
This commit is contained in:
parent
657866c3bc
commit
840a749716
1 changed files with 17 additions and 2 deletions
|
@ -358,7 +358,7 @@ namespace System
|
|||
return val1 + (val2 - val1) * pct;
|
||||
}
|
||||
|
||||
public static T Min<T>(T val1, T val2) where T : IOpComparable, IIsNaN
|
||||
public static T Min<T>(T val1, T val2) where bool : operator T < T where T : IIsNaN
|
||||
{
|
||||
if (val1 < val2)
|
||||
return val1;
|
||||
|
@ -369,7 +369,14 @@ namespace System
|
|||
return val2;
|
||||
}
|
||||
|
||||
public static T Max<T>(T val1, T val2) where T : IOpComparable, IIsNaN
|
||||
public static T Min<T>(T val1, T val2) where bool : operator T < T
|
||||
{
|
||||
if (val1 < val2)
|
||||
return val1;
|
||||
return val2;
|
||||
}
|
||||
|
||||
public static T Max<T>(T val1, T val2) where bool : operator T > T where T : IIsNaN
|
||||
{
|
||||
if (val1 > val2)
|
||||
return val1;
|
||||
|
@ -380,6 +387,14 @@ namespace System
|
|||
return val2;
|
||||
}
|
||||
|
||||
public static T Max<T>(T val1, T val2) where bool : operator T > T
|
||||
{
|
||||
if (val1 > val2)
|
||||
return val1;
|
||||
|
||||
return val2;
|
||||
}
|
||||
|
||||
public static float Log(float a, float newBase)
|
||||
{
|
||||
if (a.IsNaN)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue