2022-08-23

How to fix the number of decimals to 500 digits output in Python?

In the following example:

import math
x = math.log(2)
print("{:.500f}".format(x))    

I tried to get 500 digits output I get only 53 decimals output of ln(2) as follows:

0.69314718055994528622676398299518041312694549560546875000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

How I can fix this problem?



No comments:

Post a Comment