[Tutor] decimal precision in python

James Reynolds eire1130 at gmail.com
Mon Feb 6 16:41:24 CET 2012


On Mon, Feb 6, 2012 at 10:25 AM, Kapil Shukla <shukla.kapil at gmail.com>wrote:

> i tried writing a small code to calculate option price using the binomial
> tree model. I compared my results with results of the same program in
> excel. There seems to be a minor difference due to decimal precision as
> excel is using 15 decimal precision and python (both 2.7 and 3.1) using 11.
> (at least that's what shown on shell)
>
> can some one guide me whats the equivalent of using a double datatype on
> python and i can't use long() in 3.1 any more.
>
> Please also suggest a free editor for python which can at least repeat
> previous command with a key stroke
>
> regards
> kapil
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>
Have you looked into the decimal module? (you need to import decimal)

http://docs.python.org/library/decimal.html

You can specify the amount of precision needed.

Also, i would suggest using 3.2, if it's not too late in your project.

As for editors, I hear VIM is good. I use Eclipse as an IDE personally.
People seem to have some fairly definite ideas on what editor other people
should use, bordering on religious fanaticism.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120206/d1577199/attachment-0001.html>


More information about the Tutor mailing list