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

Re: [Tutor] decimal precision

2008-03-25 Thread bob gailer
elis aeris wrote: [snip] I echo Dick Moore. Several of us have requested that you study the tutorials. We continue to see no evidence that you are doing that, nor have you told us you are reading them or why not. Please respond by telling us you are reading the tutorials or if not why not. If

Re: [Tutor] decimal precision

2008-03-25 Thread Dick Moores
Elis, You could have found the solutions to your various puzzlements by reading in Alan's tutorial, < http://www.freenetpages.co.uk/hp/alan.gauld/> The page reached by the "Simple Sequences" link probably is all you need.  Why don't you use these extremely useful sources of help? Dick Moores At

Re: [Tutor] decimal precision

2008-03-25 Thread Michael Connors
On 25/03/2008, elis aeris <[EMAIL PROTECTED]> wrote: > > what if i want it only to 2nd decimal? > > what if i want to cut off everything behind decimal? > In: print "%.2f" % (0.99) Out: 0.99 http://docs.python.org/lib/typesseq-strings.html -- Michael Connors

Re: [Tutor] decimal precision

2008-03-25 Thread elis aeris
what if i want it only to 2nd decimal? what if i want to cut off everything behind decimal? On Tue, Mar 25, 2008 at 6:30 AM, Michael Connors <[EMAIL PROTECTED]> wrote: > > On 25/03/2008, elis aeris <[EMAIL PROTECTED]> wrote: > > > x = 53 > > w = 192 > > for a in range ( x, (x+192) ): > > pri

Re: [Tutor] decimal precision

2008-03-25 Thread Michael Connors
On 25/03/2008, elis aeris <[EMAIL PROTECTED]> wrote: > > x = 53 > w = 192 > for a in range ( x, (x+192) ): > print (a-x)/w > > > the problem is at (a-x)/w > > it's supposed to return a ratio between x and w, yet it 0 all the time. > > ___ > Tutor mail

Re: [Tutor] decimal precision

2008-03-25 Thread Michael Connors
On 25/03/2008, elis aeris <[EMAIL PROTECTED]> wrote: > > x = 53 > w = 192 > for a in range ( x, (x+192) ): > print (a-x)/w > > > the problem is at (a-x)/w > > it's supposed to return a ratio between x and w, yet it 0 all the time. > > ___ > Tutor mail

[Tutor] decimal precision

2008-03-25 Thread elis aeris
x = 53 w = 192 for a in range ( x, (x+192) ): print (a-x)/w the problem is at (a-x)/w it's supposed to return a ratio between x and w, yet it 0 all the time. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor