Re: [Tutor] decimal precision in python

2012-02-07 Thread Steve Willoughby
On 07-Feb-12 03:15, Steven D'Aprano wrote: Steve Willoughby wrote: If you need lots of precision, you might consider using the decimal class. It'll cost you speed vs. the native floating-point type but won't cause you round-off errors. I'm afraid that's not correct. Decimal is still subject to

Re: [Tutor] decimal precision in python

2012-02-07 Thread Steven D'Aprano
Col, I think you wrote to me personally by accident, instead of to the Tutor list. Nothing you said seems to be private, so I've taken the liberty of answering back on the list. col speed wrote: Just an idea - I'm not an expert by any means, just a dabbler, but: many years ago, when I was l

Re: [Tutor] decimal precision in python

2012-02-07 Thread Steven D'Aprano
Steve Willoughby wrote: On 06-Feb-12 07:25, Kapil Shukla 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 1

Re: [Tutor] decimal precision in python

2012-02-06 Thread Modulok
For money, you should probably use the builtin module 'decimal' instead: http://docs.python.org/library/decimal.html There's also the third party module 'mpmath' which provides arbitrary precision floating point arithmetic. http://mpmath.googlecode.com/svn/trunk/doc/build/index.html -Modulok-

Re: [Tutor] decimal precision in python

2012-02-06 Thread Dave Angel
On 02/06/2012 10:25 AM, Kapil Shukla 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 a

Re: [Tutor] decimal precision in python

2012-02-06 Thread James Reynolds
On Mon, Feb 6, 2012 at 10:25 AM, Kapil Shukla 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 dec

Re: [Tutor] decimal precision in python

2012-02-06 Thread Steve Willoughby
On 06-Feb-12 07:25, Kapil Shukla 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 p

[Tutor] decimal precision in python

2012-02-06 Thread Kapil Shukla
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 lea