diff --git a/src/FixedPointNano/FixedPointNano.cs b/src/FixedPointNano/FixedPointNano.cs
index db16af6..aacb67e 100644
--- a/src/FixedPointNano/FixedPointNano.cs
+++ b/src/FixedPointNano/FixedPointNano.cs
@@ -135,6 +135,30 @@ public static bool IsInteger(FixedPointNano value)
return value.RawValue % Scale == 0;
}
+ /// Returns if is strictly greater than zero.
+ /// The value to test.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static bool IsPositive(FixedPointNano value)
+ {
+ return value.RawValue > 0;
+ }
+
+ /// Returns if is strictly less than zero.
+ /// The value to test.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static bool IsNegative(FixedPointNano value)
+ {
+ return value.RawValue < 0;
+ }
+
+ /// Returns if is exactly zero.
+ /// The value to test.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static bool IsZero(FixedPointNano value)
+ {
+ return value.RawValue == 0;
+ }
+
public static FixedPointNano FromDecimal(decimal value)
{
var scaledValue = decimal.Round(value * Scale, 0, MidpointRounding.ToEven);
diff --git a/tests/FixedPointNano.Tests/FixedPointNanoTests.cs b/tests/FixedPointNano.Tests/FixedPointNanoTests.cs
index 2795000..2a6e7bf 100644
--- a/tests/FixedPointNano.Tests/FixedPointNanoTests.cs
+++ b/tests/FixedPointNano.Tests/FixedPointNanoTests.cs
@@ -36,6 +36,38 @@ public void IsIntegerShouldDetectWholeness()
Assert.That(FixedPointNano.IsInteger(FixedPointNano.FromDecimal(-2m)), Is.True);
}
+ [Test]
+ public void IsPositiveShouldReturnTrueOnlyForPositiveValues()
+ {
+ Assert.That(FixedPointNano.IsPositive(FixedPointNano.Zero), Is.False);
+ Assert.That(FixedPointNano.IsPositive(FixedPointNano.Epsilon), Is.True);
+ Assert.That(FixedPointNano.IsPositive(FixedPointNano.One), Is.True);
+ Assert.That(FixedPointNano.IsPositive(FixedPointNano.MaxValue), Is.True);
+ Assert.That(FixedPointNano.IsPositive(FixedPointNano.NegativeOne), Is.False);
+ Assert.That(FixedPointNano.IsPositive(FixedPointNano.MinValue), Is.False);
+ }
+
+ [Test]
+ public void IsNegativeShouldReturnTrueOnlyForNegativeValues()
+ {
+ Assert.That(FixedPointNano.IsNegative(FixedPointNano.Zero), Is.False);
+ Assert.That(FixedPointNano.IsNegative(FixedPointNano.Epsilon), Is.False);
+ Assert.That(FixedPointNano.IsNegative(FixedPointNano.One), Is.False);
+ Assert.That(FixedPointNano.IsNegative(FixedPointNano.MaxValue), Is.False);
+ Assert.That(FixedPointNano.IsNegative(FixedPointNano.NegativeOne), Is.True);
+ Assert.That(FixedPointNano.IsNegative(FixedPointNano.MinValue), Is.True);
+ }
+
+ [Test]
+ public void IsZeroShouldReturnTrueOnlyForZero()
+ {
+ Assert.That(FixedPointNano.IsZero(FixedPointNano.Zero), Is.True);
+ Assert.That(FixedPointNano.IsZero(FixedPointNano.Epsilon), Is.False);
+ Assert.That(FixedPointNano.IsZero(-FixedPointNano.Epsilon), Is.False);
+ Assert.That(FixedPointNano.IsZero(FixedPointNano.One), Is.False);
+ Assert.That(FixedPointNano.IsZero(FixedPointNano.NegativeOne), Is.False);
+ }
+
[Test]
public void FractionalPartShouldReturnDecimalComponent()
{