Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mpfr numbers are limited to 301,033 digits #253

Closed
the-stanely opened this issue Sep 27, 2019 · 0 comments
Closed

mpfr numbers are limited to 301,033 digits #253

the-stanely opened this issue Sep 27, 2019 · 0 comments

Comments

@the-stanely
Copy link

the-stanely commented Sep 27, 2019

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.

Thanks for looking at this.

gmpy2-mpfr-test.py.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant