diff --git a/mpir.net/mpir.net-tests/HugeFloatTests/Conversions.cs b/mpir.net/mpir.net-tests/HugeFloatTests/Conversions.cs index b1ea338e..fff89e65 100644 --- a/mpir.net/mpir.net-tests/HugeFloatTests/Conversions.cs +++ b/mpir.net/mpir.net-tests/HugeFloatTests/Conversions.cs @@ -358,5 +358,16 @@ namespace MPIR.Tests.HugeFloatTests Assert.IsFalse(b.FitsUshort()); } } + + [TestMethod] + public void FloatIsInteger() + { + using (var a = new HugeFloat("-233454059287409285742345.125")) + { + Assert.IsFalse(a.IsInteger()); + a.Value = a * 8; + Assert.IsTrue(a.IsInteger()); + } + } } } diff --git a/mpir.net/mpir.net/HugeFloat.h b/mpir.net/mpir.net/HugeFloat.h index 0611a009..994cab1d 100644 --- a/mpir.net/mpir.net/HugeFloat.h +++ b/mpir.net/mpir.net/HugeFloat.h @@ -1223,6 +1223,12 @@ namespace MPIR /// true if the value will fit in a short bool FitsUshort() { return MP(fits_ushort_p)(_value) != 0; } + /// + /// Returns true if the source number is a whole integer. + /// + /// true if the value is an integer + bool IsInteger() { return MP(integer_p)(_value) != 0; } + #pragma endregion #pragma region IO