Okay, if I change m_apm_integer_pow() to use m_apm_iround(r, -1), which disables rounding, this shows matching results for $base() and $base2().

The m_apm_iround(r, places + X) function is used throughout MAPM with extra X, presumably to extend the rounding precision after a calculation to cater for a larger value result. The X value varies throughout the code.

There is a m_apm_cpp_precision() that allows you to set the minimum precision for the entire library. If you set it too low, it is overriden by the maximum number of digits in the calculation parameters to ensure sufficient precision.

For now, I am going to call m_apm_cpp_precision() with a very large value to effectively set unlimited precision. This affects all calls to the MAPM library. This will be in the next beta.

Update: Right. I see what is happening. In m_apm_integer_pow(), it calls M_integer_pos_pow() and sets r with the result and passes it to m_apm_iround(r, places) to round. However, the "places" value is based on the value of r prior to the power being calculated, so it is not of sufficient precision for the result. m_apm_iround() is used in this way in many functions, where the result is rounded to the largest decimal place in the input parameter, leading to precision loss (although in many places, the decimal place length is extended by varying X amounts but this is not consistent). In any case, at this point, the best option seems to be to bypass all of this and just call m_apm_cpp_precision() with a large number.

Update: Aaand... that was a bad idea :-) m_apm_cpp_precision() with larger values slows down MAPM significantly since it isn't just used as a rounding value but as actual calculated precision length. So, instead, I am going to fix the ^ issue by just using m_apm_iround(r, -1) in the m_apm_integer_pow() function. If any other functions show similar precision issues to ^, I will change them individually as necessary.

Last edited by Khaled; 27/10/22 10:30 AM.