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 efe20306..4a169b77 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 @@ -94,15 +94,9 @@ - - HugeFloatTests\Arithmetic.cs - HugeFloatTests\Assignment.cs - - HugeFloatTests\Comparisons.cs - HugeFloatTests\Arithmetic.cs @@ -115,12 +109,6 @@ HugeFloatTests\Conversions.cs - - HugeFloatTests\ExpressionTests.cs - - - HugeFloatTests\IO.cs - HugeFloatTests\ExpressionTests.cs diff --git a/build.vc11/mpir.net/mpir.net/mpir.net.vcxproj b/build.vc11/mpir.net/mpir.net/mpir.net.vcxproj index 0599225f..b723b67b 100644 --- a/build.vc11/mpir.net/mpir.net/mpir.net.vcxproj +++ b/build.vc11/mpir.net/mpir.net/mpir.net.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -28,28 +28,28 @@ DynamicLibrary true - v110 + v120 true Unicode DynamicLibrary true - v110 + v120 true Unicode DynamicLibrary false - v110 + v120 true Unicode DynamicLibrary false - v110 + v120 true Unicode @@ -96,6 +96,7 @@ true ..\..\..\lib\$(Platform)\$(Configuration)\mpir.lib + LIBCMT;%(IgnoreSpecificDefaultLibraries) @@ -109,6 +110,7 @@ true ..\..\..\lib\$(Platform)\$(Configuration)\mpir.lib + LIBCMT;%(IgnoreSpecificDefaultLibraries) @@ -121,6 +123,7 @@ true ..\..\..\lib\$(Platform)\$(Configuration)\mpir.lib + LIBCMT;%(IgnoreSpecificDefaultLibraries) @@ -133,6 +136,7 @@ true ..\..\..\lib\$(Platform)\$(Configuration)\mpir.lib + LIBCMT;%(IgnoreSpecificDefaultLibraries) diff --git a/mpir.net/mpir.net/AssemblyInfo.cpp b/mpir.net/mpir.net/AssemblyInfo.cpp index 4cd0b600..23d47567 100644 --- a/mpir.net/mpir.net/AssemblyInfo.cpp +++ b/mpir.net/mpir.net/AssemblyInfo.cpp @@ -53,5 +53,5 @@ using namespace System::Security::Permissions; [assembly:AssemblyVersionAttribute("1.0.0.0")]; [assembly:ComVisible(false)]; [assembly:CLSCompliantAttribute(true)]; -[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; +//obsolete in .Net 4.0 [assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; [assembly:InternalsVisibleTo("mpir.net-tests")]; diff --git a/mpir.net/mpir.net/Common.h b/mpir.net/mpir.net/Common.h index aa252e94..eba5ca91 100644 --- a/mpir.net/mpir.net/Common.h +++ b/mpir.net/mpir.net/Common.h @@ -147,7 +147,7 @@ struct EvaluationContext Zero = 0; } -#define CTXT_ADD_RATIONAL(numerator, denominator) \ +#define CTXT_ADD_RATIONAL_SI(numerator, denominator) \ auto ptr = &context.Temp[context.Index].Rational; \ context.RationalArgs[context.Index++] = ptr; \ \ @@ -161,6 +161,20 @@ struct EvaluationContext ptr->_mp_den._mp_size = (int)SGN(denominator); \ ptr->_mp_den._mp_d = &_d; +#define CTXT_ADD_RATIONAL_UI(numerator, denominator) \ + auto ptr = &context.Temp[context.Index].Rational; \ + context.RationalArgs[context.Index++] = ptr; \ + \ + auto _n = (mpir_ui)numerator; \ + ptr->_mp_num._mp_alloc = 1; \ + ptr->_mp_num._mp_size = (int)SGN(numerator); \ + ptr->_mp_num._mp_d = &_n; \ + \ + auto _d = (mpir_ui)denominator; \ + ptr->_mp_den._mp_alloc = 1; \ + ptr->_mp_den._mp_size = (int)SGN(denominator); \ + ptr->_mp_den._mp_d = &_d; + #define CTXT_ADD_RATIONAL_DOUBLE(value) \ context.Initialized(RationalInitialized); \ auto ptr = &context.Temp[context.Index].Rational; \ diff --git a/mpir.net/mpir.net/ExpressionMacros.h b/mpir.net/mpir.net/ExpressionMacros.h index 5119f1b2..2147f53c 100644 --- a/mpir.net/mpir.net/ExpressionMacros.h +++ b/mpir.net/mpir.net/ExpressionMacros.h @@ -233,11 +233,19 @@ private ref class MPEXPR(name) : base operation(destination, destination, Right); \ } -#define DEFINE_BINARY_ASSIGNMENT_REF_RATVAL(name, leftTypeAbbr, rightTypeAbbr, operation) \ +#define DEFINE_BINARY_ASSIGNMENT_REF_RATUI(name, leftTypeAbbr, rightTypeAbbr, operation) \ DEFINE_ASSIGNMENT_PROLOG(name##leftTypeAbbr##rightTypeAbbr) \ { \ IN_CONTEXT(Left); \ - CTXT_ADD_RATIONAL(Right, 1); \ + CTXT_ADD_RATIONAL_UI(Right, 1); \ + operation(destination, CTXT(0), CTXT(1)); \ + } + +#define DEFINE_BINARY_ASSIGNMENT_REF_RATSI(name, leftTypeAbbr, rightTypeAbbr, operation) \ + DEFINE_ASSIGNMENT_PROLOG(name##leftTypeAbbr##rightTypeAbbr) \ + { \ + IN_CONTEXT(Left); \ + CTXT_ADD_RATIONAL_SI(Right, 1); \ operation(destination, CTXT(0), CTXT(1)); \ } @@ -248,11 +256,19 @@ private ref class MPEXPR(name) : base operation(destination, Left, destination); \ } -#define DEFINE_BINARY_ASSIGNMENT_RATVAL_REF(name, leftTypeAbbr, rightTypeAbbr, operation) \ +#define DEFINE_BINARY_ASSIGNMENT_RATUI_REF(name, leftTypeAbbr, rightTypeAbbr, operation) \ DEFINE_ASSIGNMENT_PROLOG(name##leftTypeAbbr##rightTypeAbbr) \ { \ IN_CONTEXT(Right); \ - CTXT_ADD_RATIONAL(Left, 1); \ + CTXT_ADD_RATIONAL_UI(Left, 1); \ + operation(destination, CTXT(1), CTXT(0)); \ + } + +#define DEFINE_BINARY_ASSIGNMENT_RATSI_REF(name, leftTypeAbbr, rightTypeAbbr, operation) \ + DEFINE_ASSIGNMENT_PROLOG(name##leftTypeAbbr##rightTypeAbbr) \ + { \ + IN_CONTEXT(Right); \ + CTXT_ADD_RATIONAL_SI(Left, 1); \ operation(destination, CTXT(1), CTXT(0)); \ } diff --git a/mpir.net/mpir.net/HugeFloat.h b/mpir.net/mpir.net/HugeFloat.h index f956d1aa..bdf9379a 100644 --- a/mpir.net/mpir.net/HugeFloat.h +++ b/mpir.net/mpir.net/HugeFloat.h @@ -366,7 +366,7 @@ namespace MPIR /// Value to compare the source with /// The number of most significant bits that must match for the two numbers to be considered equal /// true if the values of the source and are equal to , false otherwise. - bool Equals(MPEXPR_NAME^ a, mp_bitcnt_t precision) { IN_CONTEXT(this, a); return MP(eq)(CTXT(0), CTXT(1), precision); } + bool Equals(MPEXPR_NAME^ a, mp_bitcnt_t precision) { IN_CONTEXT(this, a); return MP(eq)(CTXT(0), CTXT(1), precision) != 0; } /// Computes the hash code of the source value. /// If called on an expression, it is evaluated into a temporary variable before the comparison is performed. @@ -1314,7 +1314,7 @@ namespace MPIR /// Text reader to input the number from /// The base to use for the mantissa. /// The base can be from 2 to 62; uppercase letters represent digits 10-35 while lowercase letters represent digits 36-61. - /// For bases larger than 36, the argument is ignored and uppercase letters represent digits 10-35 while lowercase letters represent digits 36-61. + /// For bases 36 and less, uppercase and lowercase letters are equivalent. /// the number of characters read size_t Read(TextReader^ reader, int base) { return Read(reader, base, true); } diff --git a/mpir.net/mpir.net/HugeInt.h b/mpir.net/mpir.net/HugeInt.h index f54d9f9b..12ee440e 100644 --- a/mpir.net/mpir.net/HugeInt.h +++ b/mpir.net/mpir.net/HugeInt.h @@ -1918,7 +1918,7 @@ namespace MPIR auto bitsPerLimb = 8 * bytesPerLimb - nails; auto limbCount = (MP(sizeinbase)(_value, 2) - 1) / bitsPerLimb + 1; auto arrayCount = (limbCount * bytesPerLimb - 1) / sizeof(T) + 1; - auto data = gcnew array(arrayCount); + auto data = gcnew array((int)arrayCount); PIN(data); MP(export)(pinned_data, &limbCount, (int)limbOrder, bytesPerLimb, (int)endianness, nails, _value); diff --git a/mpir.net/mpir.net/HugeRational.cpp b/mpir.net/mpir.net/HugeRational.cpp index cd679381..6bb74eeb 100644 --- a/mpir.net/mpir.net/HugeRational.cpp +++ b/mpir.net/mpir.net/HugeRational.cpp @@ -234,14 +234,14 @@ namespace MPIR if(a->GetType() == mpir_ui::typeid) { ASSIGN_TO(context); - CTXT_ADD_RATIONAL((mpir_ui)a, 1); + CTXT_ADD_RATIONAL_UI((mpir_ui)a, 1); return MP(equal)(CTXT(0), CTXT(1)) != 0; } if(a->GetType() == mpir_si::typeid) { ASSIGN_TO(context); - CTXT_ADD_RATIONAL((mpir_si)a, 1); + CTXT_ADD_RATIONAL_SI((mpir_si)a, 1); return MP(equal)(CTXT(0), CTXT(1)) != 0; } @@ -267,14 +267,14 @@ namespace MPIR bool MPEXPR_NAME::Equals(mpir_si numerator, mpir_ui denominator) { IN_CONTEXT(this); - CTXT_ADD_RATIONAL(numerator, denominator); + CTXT_ADD_RATIONAL_SI(numerator, denominator); return MP(equal)(CTXT(0), CTXT(1)) != 0; } bool MPEXPR_NAME::Equals(mpir_ui numerator, mpir_ui denominator) { IN_CONTEXT(this); - CTXT_ADD_RATIONAL(numerator, denominator); + CTXT_ADD_RATIONAL_UI(numerator, denominator); return MP(equal)(CTXT(0), CTXT(1)) != 0; } @@ -328,28 +328,28 @@ namespace MPIR DEFINE_UNARY_ASSIGNMENT_REF(Abs, Rat, MP(abs)) DEFINE_BINARY_ASSIGNMENT_REF_REF(Add, Rat, MP(add)) - DEFINE_BINARY_ASSIGNMENT_REF_RATVAL(Add, Rat, Ui, MP(add)) - DEFINE_BINARY_ASSIGNMENT_REF_RATVAL(Add, Rat, Si, MP(add)) + DEFINE_BINARY_ASSIGNMENT_REF_RATUI(Add, Rat, Ui, MP(add)) + DEFINE_BINARY_ASSIGNMENT_REF_RATSI(Add, Rat, Si, MP(add)) DEFINE_BINARY_ASSIGNMENT_REF_INTVAL(Add, Rat, IExpr, MP(add)) DEFINE_BINARY_ASSIGNMENT_REF_REF(Subtract, Rat, MP(sub)) - DEFINE_BINARY_ASSIGNMENT_REF_RATVAL(Subtract, Rat, Ui, MP(sub)) - DEFINE_BINARY_ASSIGNMENT_RATVAL_REF(Subtract, Ui, Rat, MP(sub)) - DEFINE_BINARY_ASSIGNMENT_REF_RATVAL(Subtract, Rat, Si, MP(sub)) - DEFINE_BINARY_ASSIGNMENT_RATVAL_REF(Subtract, Si, Rat, MP(sub)) + DEFINE_BINARY_ASSIGNMENT_REF_RATUI(Subtract, Rat, Ui, MP(sub)) + DEFINE_BINARY_ASSIGNMENT_RATUI_REF(Subtract, Ui, Rat, MP(sub)) + DEFINE_BINARY_ASSIGNMENT_REF_RATSI(Subtract, Rat, Si, MP(sub)) + DEFINE_BINARY_ASSIGNMENT_RATSI_REF(Subtract, Si, Rat, MP(sub)) DEFINE_BINARY_ASSIGNMENT_REF_INTVAL(Subtract, Rat, IExpr, MP(sub)) DEFINE_BINARY_ASSIGNMENT_REF_INTVAL(Subtract, IExpr, Rat, MP(sub)) DEFINE_BINARY_ASSIGNMENT_REF_REF(Multiply, Rat, MP(mul)) - DEFINE_BINARY_ASSIGNMENT_REF_RATVAL(Multiply, Rat, Ui, MP(mul)) - DEFINE_BINARY_ASSIGNMENT_REF_RATVAL(Multiply, Rat, Si, MP(mul)) + DEFINE_BINARY_ASSIGNMENT_REF_RATUI(Multiply, Rat, Ui, MP(mul)) + DEFINE_BINARY_ASSIGNMENT_REF_RATSI(Multiply, Rat, Si, MP(mul)) DEFINE_BINARY_ASSIGNMENT_REF_INTVAL(Multiply, Rat, IExpr, MP(mul)) DEFINE_BINARY_ASSIGNMENT_REF_REF(Divide, Rat, MP(div)) - DEFINE_BINARY_ASSIGNMENT_REF_RATVAL(Divide, Rat, Ui, MP(div)) - DEFINE_BINARY_ASSIGNMENT_RATVAL_REF(Divide, Ui, Rat, MP(div)) - DEFINE_BINARY_ASSIGNMENT_REF_RATVAL(Divide, Rat, Si, MP(div)) - DEFINE_BINARY_ASSIGNMENT_RATVAL_REF(Divide, Si, Rat, MP(div)) + DEFINE_BINARY_ASSIGNMENT_REF_RATUI(Divide, Rat, Ui, MP(div)) + DEFINE_BINARY_ASSIGNMENT_RATUI_REF(Divide, Ui, Rat, MP(div)) + DEFINE_BINARY_ASSIGNMENT_REF_RATSI(Divide, Rat, Si, MP(div)) + DEFINE_BINARY_ASSIGNMENT_RATSI_REF(Divide, Si, Rat, MP(div)) DEFINE_BINARY_ASSIGNMENT_REF_INTVAL(Divide, Rat, IExpr, MP(div)) DEFINE_BINARY_ASSIGNMENT_REF_INTVAL(Divide, IExpr, Rat, MP(div))