0

Hello all

I'm having a few issues with a Python program in that I am performing decimal calculations on and most values come up as desired, however every so often, when there is a very small decimal, the number is represented like "6.80E-7" rather than the desired "0.000000680". Here's a snippet of the code that I'm using:

import decimal
decimal.getcontext().prec = 9
now = "230.939809280"
then = "230.939808600"
print str(decimal.Decimal(now) - decimal.Decimal(then))

This gives the following response:

6.80E-7

Does anyone know of a way for me to display this output as "0.000000680" instead?

Any help would be most appreciated :)

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by Simplified
0
decimal.getcontext().prec = 9
now = "230.939809280"
then = "230.939808600"
print "%.9f" % (decimal.Decimal(now) - decimal.Decimal(then))
# -> 0.000000680
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.