Search code examples
pythonalgorithmfloating-pointsquare-rootnewtons-method

print arbitrary amount of digits of float


How can I print more than about 10 digits of a float in python? Right now, when do

print sqr_newton(10, 3, 0.001) (where sqr_newton is newton's algorithm for square roots; returns a float)

it only gives so many digits after the decimal place... how can I get more?


Solution

  • That is the standard precision for floats in python.

    For arbitrary precision, you can use the bigfloat package.