diff --git a/build.vc11/mpir.net/mpir.net-tests/mpir.net-tests.csproj b/build.vc11/mpir.net/mpir.net-tests/mpir.net-tests.csproj
index 3c265ec4..b13c3ad7 100644
--- a/build.vc11/mpir.net/mpir.net-tests/mpir.net-tests.csproj
+++ b/build.vc11/mpir.net/mpir.net-tests/mpir.net-tests.csproj
@@ -172,8 +172,11 @@
IntegrationTests\XmlCommentsTests.cs
-
- RandomTests\Random.cs
+
+ OtherTests\MpirSettings.cs
+
+
+ OtherTests\Random.cs
Utilities\Accessors.cs
diff --git a/build.vc12/mpir.net/mpir.net-tests/mpir.net-tests.csproj b/build.vc12/mpir.net/mpir.net-tests/mpir.net-tests.csproj
index 3c265ec4..b13c3ad7 100644
--- a/build.vc12/mpir.net/mpir.net-tests/mpir.net-tests.csproj
+++ b/build.vc12/mpir.net/mpir.net-tests/mpir.net-tests.csproj
@@ -172,8 +172,11 @@
IntegrationTests\XmlCommentsTests.cs
-
- RandomTests\Random.cs
+
+ OtherTests\MpirSettings.cs
+
+
+ OtherTests\Random.cs
Utilities\Accessors.cs
diff --git a/build.vc14/mpir.net/mpir.net-tests/mpir.net-tests.csproj b/build.vc14/mpir.net/mpir.net-tests/mpir.net-tests.csproj
index c4aa119e..b729b456 100644
--- a/build.vc14/mpir.net/mpir.net-tests/mpir.net-tests.csproj
+++ b/build.vc14/mpir.net/mpir.net-tests/mpir.net-tests.csproj
@@ -173,8 +173,11 @@
IntegrationTests\XmlCommentsTests.cs
-
- RandomTests\Random.cs
+
+ OtherTests\MpirSettings.cs
+
+
+ OtherTests\Random.cs
Utilities\Accessors.cs
diff --git a/mpir.net/mpir.net-tests/IntegrationTests/XmlCommentsTests.cs b/mpir.net/mpir.net-tests/IntegrationTests/XmlCommentsTests.cs
index c34d7e8c..29ff6194 100644
--- a/mpir.net/mpir.net-tests/IntegrationTests/XmlCommentsTests.cs
+++ b/mpir.net/mpir.net-tests/IntegrationTests/XmlCommentsTests.cs
@@ -34,7 +34,7 @@ namespace MPIR.Tests.HugeIntTests
[TestClass]
public class XmlCommentsTests
{
- private static readonly string[] ValidMemberTypePrefixes = { "M:", "P:", "F:" };
+ private static readonly string[] ValidMemberTypePrefixes = { "M:", "P:", "F:", "C:" };
[TestMethod]
public void TestComments()
diff --git a/mpir.net/mpir.net-tests/OtherTests/MpirSettings.cs b/mpir.net/mpir.net-tests/OtherTests/MpirSettings.cs
new file mode 100644
index 00000000..49ed90c1
--- /dev/null
+++ b/mpir.net/mpir.net-tests/OtherTests/MpirSettings.cs
@@ -0,0 +1,104 @@
+/*
+Copyright 2014 Alex Dyachenko
+
+This file is part of the MPIR Library.
+
+The MPIR Library is free software; you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published
+by the Free Software Foundation; either version 3 of the License, or (at
+your option) any later version.
+
+The MPIR Library is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with the MPIR Library. If not, see http://www.gnu.org/licenses/.
+*/
+
+using System;
+using System.IO;
+using System.Text;
+using System.Linq;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace MPIR.Tests.RandomTests
+{
+ [TestClass]
+ public class MpirSettingsTests
+ {
+ [TestMethod]
+ public void BitsPerLimb()
+ {
+ unsafe
+ {
+ Assert.AreEqual(8 * sizeof(IntPtr), MpirSettings.BITS_PER_LIMB);
+ Assert.AreEqual(8 * sizeof(IntPtr), MpirSettings.USABLE_BITS_PER_LIMB);
+ Assert.AreEqual(0, MpirSettings.NAIL_BITS_PER_LIMB);
+ }
+ }
+
+ [TestMethod]
+ public void Version()
+ {
+ Assert.AreEqual("5.1.3", MpirSettings.GMP_VERSION.ToString());
+ Assert.AreEqual("2.7.2", MpirSettings.MPIR_VERSION.ToString());
+ }
+
+ [TestMethod]
+ public void ToStringDigits()
+ {
+ const string strA = "9520398475029834502983475028934705982734095827304958723409758230498573034928750938475987498473958743";
+ using (var a = new HugeInt(strA))
+ {
+ Assert.AreEqual(256, MpirSettings.ToStringDigits);
+ Assert.AreEqual(strA, a.ToString());
+
+ MpirSettings.ToStringDigits = 32;
+ Assert.AreEqual("..." + strA.Substring(strA.Length - 32), a.ToString());
+
+ MpirSettings.ToStringDigits = 256;
+ Assert.AreEqual(strA, a.ToString());
+ }
+ }
+
+ [TestMethod]
+ public void RoundingMode()
+ {
+ const string strA = "9520398475029834502983475028934705982734095827304958723409758230498573034928750938475987498473958743";
+ var down = strA.Substring(0, strA.Length - 1);
+ var up = strA.Substring(0, strA.Length - 2) + (char) (strA[strA.Length - 2] + 1);
+
+ using (var a = new HugeInt(strA))
+ using (var b = new HugeInt())
+ {
+ Assert.AreEqual(RoundingModes.Truncate, MpirSettings.RoundingMode);
+ b.Value = a / 10;
+ Assert.AreEqual(down, b.ToString());
+ b.Value = -a / 10;
+ Assert.AreEqual("-" + down, b.ToString());
+
+ MpirSettings.RoundingMode = RoundingModes.Default;
+ b.Value = a / 10;
+ Assert.AreEqual(down, b.ToString());
+ b.Value = -a / 10;
+ Assert.AreEqual("-" + down, b.ToString());
+
+ MpirSettings.RoundingMode = RoundingModes.Floor;
+ b.Value = a / 10;
+ Assert.AreEqual(down, b.ToString());
+ b.Value = -a / 10;
+ Assert.AreEqual("-" + up, b.ToString());
+
+ MpirSettings.RoundingMode = RoundingModes.Ceiling;
+ b.Value = a / 10;
+ Assert.AreEqual(up, b.ToString());
+ b.Value = -a / 10;
+ Assert.AreEqual("-" + down, b.ToString());
+
+ MpirSettings.RoundingMode = RoundingModes.Truncate;
+ }
+ }
+ }
+}
diff --git a/mpir.net/mpir.net-tests/RandomTests/Random.cs b/mpir.net/mpir.net-tests/OtherTests/Random.cs
similarity index 100%
rename from mpir.net/mpir.net-tests/RandomTests/Random.cs
rename to mpir.net/mpir.net-tests/OtherTests/Random.cs
diff --git a/mpir.net/mpir.net/HugeInt.h b/mpir.net/mpir.net/HugeInt.h
index f2686a6a..1379eb45 100644
--- a/mpir.net/mpir.net/HugeInt.h
+++ b/mpir.net/mpir.net/HugeInt.h
@@ -1019,6 +1019,35 @@ namespace MPIR
static MPTYPE^ _toStringModulo;
public:
+
+#define _GMP_VERSION __GNU_MP_VERSION + "." + __GNU_MP_VERSION_MINOR + "." + __GNU_MP_VERSION_PATCHLEVEL
+#undef GMP_VERSION
+
+ ///
+ /// Represents the total number of bits in a single MPIR limb, including data bits and nail bits
+ ///
+ literal int BITS_PER_LIMB = BITS_PER_UI;
+
+ ///
+ /// Represents the number of nail bits in a single MPIR limb. Nail bits are used internally by MPIR
+ ///
+ literal int NAIL_BITS_PER_LIMB = GMP_NAIL_BITS;
+
+ ///
+ /// Represents the number of data bits in a single MPIR limb
+ ///
+ literal int USABLE_BITS_PER_LIMB = GMP_NUMB_BITS;
+
+ ///
+ /// Represents the version of GMP with which the underlying MPIR library is compatible
+ ///
+ static initonly const Version^ GMP_VERSION = gcnew Version(_GMP_VERSION);
+
+ ///
+ /// Represents the version of the underlying MPIR library
+ ///
+ static initonly const Version^ MPIR_VERSION = gcnew Version(_MSC_MPIR_VERSION);
+
///
/// Gets or sets the default rounding mode used for MPIR division operations that don't explicitly specify a rounding mode.
/// Defaults to Truncate.