1+ namespace SharpMath
2+ {
3+ /// <summary>
4+ /// Provides extensions for comparing floating numbers using approximations.
5+ /// </summary>
6+ public static class FloatingNumberExtensions
7+ {
8+ /// <summary>
9+ /// Determines whether two floating numbers are approximately equal to each other using the <see cref="FloatingNumber.Epsilon" /> value.
10+ /// </summary>
11+ /// <param name="number">The current <see cref="float" />.</param>
12+ /// <param name="other">The other <see cref="float" />.</param>
13+ /// <returns>Returns <c>true</c>, if they are approximately equal, otherwise <c>false</c>.</returns>
14+ public static bool AreApproximatelyEqual ( this float number , float other )
15+ => FloatingNumber . AreApproximatelyEqual ( number , other ) ;
16+
17+ /// <summary>
18+ /// Determines whether two floating numbers are approximately equal to each other using the specified epsilon value.
19+ /// </summary>
20+ /// <param name="number">The current <see cref="float" />.</param>
21+ /// <param name="other">The other <see cref="float" />.</param>
22+ /// <param name="epsilon">The epsilon value that represents the tolerance.</param>
23+ /// <returns>Returns <c>true</c>, if they are approximately equal, otherwise <c>false</c>.</returns>
24+ public static bool AreApproximatelyEqual ( this float number , float other , double epsilon )
25+ => FloatingNumber . AreApproximatelyEqual ( number , other , epsilon ) ;
26+
27+ /// <summary>
28+ /// Determines whether two floating numbers are approximately equal to each other using the <see cref="Epsilon" />
29+ /// value.
30+ /// </summary>
31+ /// <param name="number">The current <see cref="float" />.</param>
32+ /// <param name="other">The other <see cref="float" />.</param>
33+ /// <returns>Returns <c>true</c>, if they are approximately equal, otherwise <c>false</c>.</returns>
34+ public static bool AreApproximatelyEqual ( double number , double other )
35+ => FloatingNumber . AreApproximatelyEqual ( number , other ) ;
36+
37+ /// <summary>
38+ /// Determines whether two floating numbers are approximately equal to each other using the specified epsilon value.
39+ /// </summary>
40+ /// <param name="number">The current <see cref="float" />.</param>
41+ /// <param name="other">The other <see cref="float" />.</param>
42+ /// <param name="epsilon">The epsilon value that represents the tolerance.</param>
43+ /// <returns>Returns <c>true</c>, if they are approximately equal, otherwise <c>false</c>.</returns>
44+ public static bool AreApproximatelyEqual ( double number , double other , double epsilon )
45+ => FloatingNumber . AreApproximatelyEqual ( number , other , epsilon ) ;
46+ }
47+ }
0 commit comments