General use:

MpfrNumber num = new MpfrNumber();
int i = num.ToInt();
Assert.AreEqual(11, i, "huh?");

The _prec member is necessary to set to get true arbitrary precision. Setting _prec via the Precision property will destroy the value that the MpfrNumber is currently holding. Use RoundPrecision to set it in a safer manner.

In order to determine how much precision you need, you have to figure out how accurate you want your numbers to be.

the equation that I calculated for prec (which I am pretty sure is right) is:
prec = 6.1 - log2(epsilon)

So, if you want to have a prec value that can handle changes as small as 1e-10, then you need a prec of:
6.1 - Log2(1e-10) = 6.1 + 33.2 = 39.3 = (or to be safe, 40)

Remember, these MpfrNumbers can be memory hogs. Don't make more of them than you have to.

Last edited Jul 28, 2011 at 9:26 PM by theTrueMikeBrown, version 2


No comments yet.