views:

1092

answers:

2

Here's my code:

x = 1.0
y = 100000.0    
print x/y

My quotient displays as 1.00000e-05

Is there any way to suppress scientific notation and make it display as 0.00001?

Thanks in advance.
This feels somewhat ridiculous to ask but I haven't figured out a way to do it yet. I'm going to use the result as a string.

+5  A: 
'%f' % (x/y)

but you need to manage precision yourself. e.g.,

'%f' % (1/10**8)

will display zeros only.
details are in the docs

SilentGhost
I knew it was pretty straightforward - thank you very much!
Matt
+3  A: 

In addition to SG's answer, you can also use the Decimal module:

 from decimal import Decimal
 x = str(Decimal(1) / Decimal(10000))

 # x is a string '0.0001'
Dana
it turns to scientific notation for values smaller than 1e-6
SilentGhost
@SilentGhost -- Ah, you're correct!
Dana