use python as a calculator
Peter Otten
__peter__ at web.de
Thu Jun 24 13:03:06 EDT 2010
ilovesss2004 wrote:
> If I run
> 1.0/10**10
> python will return 0
>
> How can I make python return 1e-10?
If you meant 1/10**10, by default this returns an integer in Python 2.x.
With "from __future__ import division" you can opt for the division of
integers to return a float:
>>> 1/10**10
0
>>> from __future__ import division
>>> 1/10**10
1e-10
Python 3.x will return a float by default.
Peter
More information about the Python-list
mailing list