-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7460b77
commit d4a143c
Showing
8 changed files
with
30 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 9 additions & 8 deletions
17
Hypercube.Mathematics/Extensions/FloatingPointEqualsExtension.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
namespace Hypercube.Mathematics.Extensions; | ||
using JetBrains.Annotations; | ||
|
||
namespace Hypercube.Mathematics.Extensions; | ||
|
||
[PublicAPI] | ||
public static class FloatingPointEqualsExtension | ||
{ | ||
public static bool AboutEquals(this double a, double b, double tolerance = 1E-15d) | ||
public static bool AboutEquals(this float a, float b, float tolerance = 1E-15f) | ||
{ | ||
var epsilon = System.Math.Max(System.Math.Abs(a), System.Math.Abs(b)) * 1E-15d; | ||
return System.Math.Abs(a - b) <= epsilon; | ||
return HyperMath.AboutEquals(a, b, tolerance); | ||
} | ||
public static bool AboutEquals(this float a, float b, float tolerance = 1E-15f) | ||
|
||
public static bool AboutEquals(this double a, double b, double tolerance = 1E-15d) | ||
{ | ||
var epsilon = System.Math.Max(System.Math.Abs(a), System.Math.Abs(b)) * tolerance ; | ||
return System.Math.Abs(a - b) <= epsilon; | ||
return HyperMath.AboutEquals(a, b, tolerance); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
Hypercube.Mathematics/Quaternion.cs → ...ube.Mathematics/Quaternions/Quaternion.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters