I use decimal objects whose values get close to zero. By default, a statement such as
print (decimal.Decimal('0.00000000004') / decimal.Decimal('2'))
will output 2E-11
. How do I prevent this from happening and get 0.00000000002
instead?
I use decimal objects whose values get close to zero. By default, a statement such as
print (decimal.Decimal('0.00000000004') / decimal.Decimal('2'))
will output 2E-11
. How do I prevent this from happening and get 0.00000000002
instead?
To get the decimal point You need to format the print
print "{:.11f}".format(decimal.Decimal('0.00000000004') / decimal.Decimal('2'))
num = decimal.Decimal('0.00000000004') / decimal.Decimal('2')
print '{:.50f}'.format(num)
print '{:.2f}'.format(num)
You can read more in documentation