Swap. Completed MPIR 2.6.0 section 5.2, except setting MPZ from MPQ or MPF

This commit is contained in:
Alex Dyachenko 2014-03-24 00:04:35 -04:00
parent fc6bfb6f4a
commit b4940574c0
2 changed files with 17 additions and 0 deletions

View File

@ -35,6 +35,20 @@ namespace MPIR.Tests.HugeIntTests
Assert.AreEqual("-222509832503450298345029835740293845720", b.ToString());
}
}
[TestMethod]
public void Swap()
{
using (var a = new HugeInt("-222509832503450298345029835740293845720"))
using (var b = new HugeInt("2039847290878794872059384789347534534"))
{
var aValue = a._value();
var bValue = b._value();
a.Swap(b);
Assert.AreEqual(bValue, a._value());
Assert.AreEqual(aValue, b._value());
}
}
//more tests coming here
}
}

View File

@ -367,5 +367,8 @@ namespace MPIR
void SetTo(double value) { mpz_set_d(_value, value); }
void SetTo(String^ value) { SetTo(value, 10); }
void SetTo(String^ value, int base);
//utility methods
void Swap(HugeInt^ a) { mpz_ptr temp = a->_value; a->_value = _value; _value = temp; }
};
};