Float IsInteger

This commit is contained in:
Alex Dyachenko 2014-06-27 12:41:46 -04:00
parent cd25b5b35c
commit 11e33c7140
2 changed files with 17 additions and 0 deletions

View File

@ -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());
}
}
}
}

View File

@ -1223,6 +1223,12 @@ namespace MPIR
/// <returns>true if the value will fit in a short</returns>
bool FitsUshort() { return MP(fits_ushort_p)(_value) != 0; }
/// <summary>
/// Returns true if the source number is a whole integer.
/// </summary>
/// <returns>true if the value is an integer</returns>
bool IsInteger() { return MP(integer_p)(_value) != 0; }
#pragma endregion
#pragma region IO