Maybe it's a bug, or a lack of documentation, (or me) but when computing base**exponent, (MAPM::pow() or m_apm_pow()) and
base>1, "decimal_places" actually specifies the number of significant digits (which certainly includes what's to the left of the decimal point) and not the number of places after the decimal point.
If you add the number below (instead of 20) to the desired number of decimal places (
when base>1) you should be safe. If you wish, I'll translate it into the non-C++ version (i.e., using m_apm_func() instead of MAPM::func()).
Code:
// this is before the decimal point; add the desired number of decimal places
INT extra (MAPM base, MAPM exponent)
{
MAPM u, mm1 = MM_One;
INT x;
u = ++((base.log10() * exponent).ceil());
CHAR *szdp = (CHAR*) AllocMem(u.significant_digits()+1);
u.toIntegerString(szdp);
x = atoi(szdp);
FreeMem(szdp);
return x;
}
I reproduced (and fixed, as above) the problem with 2**103. But I don't need the fix for .5**(-103), which is the same number. @EVAL, however, has the same problem with both.