I just learned the Decimal class in Python, and I have some issues in modifying the precision of the decimal numbers. Code:
from decimal import *
def main() :
getcontext().prec = 50
print Decimal(748327402479023).sqrt()
if __name__ == '__main__' :
main()
The output:
27355573.51764029457632865944595074348085555311409538
1.414213562373095048801688724209698078569671875376948
Instead of showing 50 decimal digits, it shows 50 digits in total. Is there a way to fix this?
Edit:
I am solving a problem which requires big floating point accuracy. That's why i have to use python. Now if the answer to the problem is for example 0.55, i should print 0.55 followed by 48 zeroes...
print "{:.50f}".format(d)
– Lactoprotein