0
Why can't my code handle very large numbers
4 Respuestas
+ 6
What do you mean by very large?
It can happily take 1 billion.
If the number is too large you may eventually hit the limitation of the float data type. There is a trade-off between number of decimal digits and precision. The amount of memory to store a single number, is fixed.
If you want more precise calculation, maybe you can try the decimal type.
https://docs.python.org/3/library/decimal.html
+ 2
As I said, it works better with the decimal type.
https://code.sololearn.com/c65e59Jc2158/?ref=app
It is correct up to 28 digit precision, because that is the default but it can be raised even further. You can figure out how, if you actually follow the link I gave before, and read it.
+ 2
you can use sympy...
import sympy
def euler(n):
print(sympy.N(sympy.E, n))
euler(2000)
0
Yes it can handle 1 billion but it cannot handle 1 septillion ,by the way is there any way to increase the storage of the number