use python as a calculator

Tim Harig usernet at ilthio.net
Thu Jun 24 11:50:53 EDT 2010


On 2010-06-24, ilovesss2004 <yyiilluuoo at gmail.com> wrote:
> If I run
> 1.0/10**10
> python will return 0

Python 2.6.4 (r264:75706, Dec 11 2009, 23:02:59) 
[GCC 3.4.6] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 1.0/10**10
1e-10
>>> 

What version are you using?

> How can I make python return 1e-10?

If necessary, cast everything to a float:

>>> 1.0/float(10**10)
1e-10
>>> 



More information about the Python-list mailing list