You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Closed...
I learned from casevh on stackoverflow that precision is specified in bits, so for n desired digits of decimal precision, n * log(10)/log(2) bits precision are needed.
Using:
64-bit, Windows 10, 1809
Anaconda Python 64-bit 3.7.3
gmpy2, GPy-1.9.8-cp37-cp37m-win_amd64.whl, installed from uci.edu.
Simple test to create a million digit number fails.
import gmpy2 # Get the gmpy2 library
print('max_precision =', gmpy2.get_max_precision())
print('emin_min =', gmpy2.get_emin_min())
print('emax_max =', gmpy2.get_emax_max())
gmpy2.get_context().precision = 1000000 + 3 # Set the precision context.
print(gmpy2.get_context())
million_string = 'a million character number for pi from http://www.eveandersson.com/pi/digits/1000000, must strip out newlines.'
print('string =', million_string)
million_pi = gmpy2.mpfr(million_string)
print('\n\nNext, print the mpfr...\n\n')
print(str(million_pi))
Printing the string representation of the million digit string works fine, showing that the input is correct. Printing the mpfr number is limited to 301,033 digits. My tests show that internal arithmetic is only performed to the same number of digits because the last digit is not being rounded correctly.
Attached is the Python script with the million digit pi as a string.
Closed...
I learned from casevh on stackoverflow that precision is specified in bits, so for n desired digits of decimal precision, n * log(10)/log(2) bits precision are needed.
Using:
Simple test to create a million digit number fails.
Printing the string representation of the million digit string works fine, showing that the input is correct. Printing the mpfr number is limited to 301,033 digits. My tests show that internal arithmetic is only performed to the same number of digits because the last digit is not being rounded correctly.
Attached is the Python script with the million digit pi as a string.
Thanks for looking at this.
gmpy2-mpfr-test.py.txt
The text was updated successfully, but these errors were encountered: