You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
843 B
C#
30 lines
843 B
C#
using System.Runtime.CompilerServices;
|
|
|
|
namespace Fusion.Addons.SimpleKCC
|
|
{
|
|
internal static class KCCFloatExtensions
|
|
{
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static bool IsNaN(this float value)
|
|
{
|
|
return float.IsNaN(value);
|
|
}
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static bool IsAlmostZero(this float value, float tolerance = 0.01f)
|
|
{
|
|
if (value < tolerance)
|
|
{
|
|
return value > 0f - tolerance;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static bool AlmostEquals(this float valueA, float valueB, float tolerance = 0.01f)
|
|
{
|
|
return (valueA - valueB).IsAlmostZero(tolerance);
|
|
}
|
|
}
|
|
} |