Reputation: 1257
I am using the Python Decimal class for precise floating-point arithmetic. I need to convert the result number consistently into a standard notation number as a string. However, very small decimal numbers are rendered in scientific notation by default.
>>> from decimal import Decimal
>>>
>>> d = Decimal("0.000001")
>>> d
Decimal('0.000001')
>>> str(d)
'0.000001'
>>> d = Decimal("0.000000001")
>>> d
Decimal('1E-9')
>>> str(d)
'1E-9'
How would I get str(d)
to return '0.000000001'
?
Upvotes: 9
Views: 3828