16 lines
391 B
C#
16 lines
391 B
C#
namespace Engine.Core;
|
|
|
|
public static class FloatExtensions
|
|
{
|
|
public static bool ApproximatelyEquals(this float a, float b)
|
|
=> ApproximatelyEquals(a, b, float.Epsilon);
|
|
public static bool ApproximatelyEquals(this float a, float b, float epsilon)
|
|
{
|
|
if (a == b)
|
|
return true;
|
|
|
|
float diff = Math.Abs(a - b);
|
|
return diff < epsilon;
|
|
}
|
|
}
|