diff --git a/mpir.net/mpir.net-tests/HugeIntTests/Assignment.cs b/mpir.net/mpir.net-tests/HugeIntTests/Assignment.cs
index cbbc8bf1..11ed394e 100644
--- a/mpir.net/mpir.net-tests/HugeIntTests/Assignment.cs
+++ b/mpir.net/mpir.net-tests/HugeIntTests/Assignment.cs
@@ -36,6 +36,17 @@ namespace MPIR.Tests.HugeIntTests
}
}
+ [TestMethod]
+ public void IntAssignRational()
+ {
+ using (var a = new HugeRational("222509832503450298345029835740293845720/7"))
+ using (var b = new HugeInt())
+ {
+ b.SetTo(a);
+ Assert.AreEqual("31787118929064328335004262248613406531", b.ToString());
+ }
+ }
+
[TestMethod]
public void IntSwap()
{
diff --git a/mpir.net/mpir.net/HugeInt.h b/mpir.net/mpir.net/HugeInt.h
index 8a0ff824..5e794573 100644
--- a/mpir.net/mpir.net/HugeInt.h
+++ b/mpir.net/mpir.net/HugeInt.h
@@ -48,6 +48,7 @@ using namespace System::Runtime::InteropServices;
namespace MPIR
{
ref class MpirRandom;
+ ref class RationalExpression;
ref class MPTYPE;
ref class MPEXPR(Divide);
ref class MPEXPR(DivideUi);
@@ -1622,6 +1623,13 @@ namespace MPIR
/// For bases 37 to 62, upper-case letter represent the usual 10..35 while lower-case letter represent 36..61.
void SetTo(String^ value, int base);
+ ///
+ /// Sets the value of the integer object. Any fractional portion is truncated.
+ /// Do not change the value of an object while it is contained in a hash table, because that changes its hash code.
+ ///
+ /// new value for the object
+ void SetTo(RationalExpression^ value);
+
///
/// Swaps the values of two integers.
/// This operation is a pointer swap and doesn't affect allocated memory.
diff --git a/mpir.net/mpir.net/HugeRational.cpp b/mpir.net/mpir.net/HugeRational.cpp
index 03140a4b..f8c9b9b4 100644
--- a/mpir.net/mpir.net/HugeRational.cpp
+++ b/mpir.net/mpir.net/HugeRational.cpp
@@ -387,4 +387,14 @@ namespace MPIR
}
#pragma endregion
+
+ #pragma region methods in other classes with rational parameters
+
+ void HugeInt::SetTo(MPEXPR_NAME^ value)
+ {
+ IN_CONTEXT(value);
+ mpz_set_q(_value, CTXT(0));
+ }
+
+ #pragma endregion
};
\ No newline at end of file