Re: finding out the precision of floats

2007-03-01 Thread greg
John Machin wrote: > Storing 1.1 and using it in calculations may save you a few > microseconds a day in your real-time apps. The main advantage would be clarity of code. > naming 1.1 as "anualRate" (sic) is utterly ludicrous. So call it annualMultiplicationFactor or something in the code. --

Re: finding out the precision of floats

2007-03-01 Thread John Machin
On Mar 1, 9:33 pm, "Bart Ogryczak" <[EMAIL PROTECTED]> wrote: > On Feb 28, 10:29 pm, "John Machin" <[EMAIL PROTECTED]> wrote: > > > > > On Mar 1, 4:19 am, "BartOgryczak" <[EMAIL PROTECTED]> wrote: > > > > On Feb 28, 3:53 pm, "John Machin" <[EMAIL PROTECTED]> wrote: > > > > > On Feb 28, 10:38 pm, "B

Re: finding out the precision of floats

2007-03-01 Thread Bart Ogryczak
On Feb 28, 10:29 pm, "John Machin" <[EMAIL PROTECTED]> wrote: > On Mar 1, 4:19 am, "BartOgryczak" <[EMAIL PROTECTED]> wrote: > > > > > On Feb 28, 3:53 pm, "John Machin" <[EMAIL PROTECTED]> wrote: > > > > On Feb 28, 10:38 pm, "BartOgryczak" <[EMAIL PROTECTED]> wrote: > > > > > [1] eg. consider calcu

Re: finding out the precision of floats

2007-02-28 Thread John Machin
On Mar 1, 4:19 am, "Bart Ogryczak" <[EMAIL PROTECTED]> wrote: > On Feb 28, 3:53 pm, "John Machin" <[EMAIL PROTECTED]> wrote: > > > On Feb 28, 10:38 pm, "BartOgryczak" <[EMAIL PROTECTED]> wrote: > > > > [1] eg. consider calculating interests rate, which often is defined as > > > math.pow(anualRate,d

Re: finding out the precision of floats

2007-02-28 Thread Arnaud Delobelle
On Feb 28, 7:28 pm, Marcin Ciura <[EMAIL PROTECTED]> wrote: > I guess that speed is not at premium in your application, > so you might try my continued fractions module, > advertised here a few weeks > ago:http://www-zo.iinf.polsl.gliwice.pl/~mciura/software/cf.py Thanks for the link, I've had a

Re: finding out the precision of floats

2007-02-28 Thread Marcin Ciura
Arnaud Delobelle wrote: > I'm not doing 'real world' calcultations, I'm making an app to help > teach children maths. I need numerical values that behave well as > decimals. I also need them to have an arbitrary number of significant > figures. Floats are great but they won't help me with either.

Re: finding out the precision of floats

2007-02-28 Thread Bart Ogryczak
On Feb 28, 6:34 pm, "Arnaud Delobelle" <[EMAIL PROTECTED]> wrote: > > So as long as you're dealing with something like > > invoices, Decimal does just fine. When you start real calculations, > > not only scientific, but even financial ones[1], it doesn't do any > > better then binary float, and it'

Re: finding out the precision of floats

2007-02-28 Thread Arnaud Delobelle
On 28 Feb, 11:38, "Bart Ogryczak" <[EMAIL PROTECTED]> wrote: > On Feb 27, 7:58 pm, "Arnaud Delobelle" <[EMAIL PROTECTED]> wrote: > > This is one of the reasons (by no means the main) why I decided to > > write my own class. > > Why not GMP? I need decimals. > My point is, that neither is Decimal.

Re: finding out the precision of floats

2007-02-28 Thread Bart Ogryczak
On Feb 28, 3:53 pm, "John Machin" <[EMAIL PROTECTED]> wrote: > On Feb 28, 10:38 pm, "BartOgryczak" <[EMAIL PROTECTED]> wrote: > > > [1] eg. consider calculating interests rate, which often is defined as > > math.pow(anualRate,days/365.0). > > In what jurisdiction for what types of transactions? I w

Re: finding out the precision of floats

2007-02-28 Thread John Machin
On Feb 28, 10:38 pm, "Bart Ogryczak" <[EMAIL PROTECTED]> wrote: > [1] eg. consider calculating interests rate, which often is defined as > math.pow(anualRate,days/365.0). In what jurisdiction for what types of transactions? I would have thought/hoped that the likelihood that any law, standard or

Re: finding out the precision of floats

2007-02-28 Thread Bart Ogryczak
On Feb 27, 7:58 pm, "Arnaud Delobelle" <[EMAIL PROTECTED]> wrote: > On 27 Feb, 14:09, "Bart Ogryczak" <[EMAIL PROTECTED]> wrote: > > > On Feb 27, 1:36 pm, Facundo Batista <[EMAIL PROTECTED]> wrote: > > > > Arnaud Delobelle wrote: > > > > (and I don't want the standard Decimal class :) > > > > Why?

Re: finding out the precision of floats

2007-02-27 Thread casevh
> Why should you? It only gives you 28 significant digits, while 64-bit > float (as in 32-bit version of Python) gives you 53 significant > digits. Also note, that on x86 FPU uses 80-bit registers. An then > Decimal executes over 1500 times slower. 64-bit floating point only gives you 53 binary bi

Re: finding out the precision of floats

2007-02-27 Thread Arnaud Delobelle
On 27 Feb, 14:09, "Bart Ogryczak" <[EMAIL PROTECTED]> wrote: > On Feb 27, 1:36 pm, Facundo Batista <[EMAIL PROTECTED]> wrote: > > > Arnaud Delobelle wrote: > > > (and I don't want the standard Decimal class :) > > > Why? > > Why should you? It only gives you 28 significant digits, while 64-bit > fl

Re: finding out the precision of floats

2007-02-27 Thread Bart Ogryczak
On Feb 27, 1:36 pm, Facundo Batista <[EMAIL PROTECTED]> wrote: > Arnaud Delobelle wrote: > > (and I don't want the standard Decimal class :) > > Why? Why should you? It only gives you 28 significant digits, while 64-bit float (as in 32-bit version of Python) gives you 53 significant digits. Also n

Re: finding out the precision of floats

2007-02-27 Thread Facundo Batista
Arnaud Delobelle wrote: > (and I don't want the standard Decimal class :) Why? -- . Facundo . Blog: http://www.taniquetil.com.ar/plog/ PyAr: http://www.python.org/ar/ -- http://mail.python.org/mailman/listinfo/python-list

Re: finding out the precision of floats

2007-02-25 Thread Robert Kern
Dennis Lee Bieber wrote: > On 25 Feb 2007 05:31:11 -0800, "John Machin" <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > >> Evidently not; here's some documentation we both need(ed) to read: >> >> http://docs.python.org/tut/node16.html >> """ >> Almost all machines today (Novem

Re: finding out the precision of floats

2007-02-25 Thread Robert Kern
John Machin wrote: > Evidently not; here's some documentation we both need(ed) to read: > > http://docs.python.org/tut/node16.html > """ > Almost all machines today (November 2000) use IEEE-754 floating point > arithmetic, and almost all platforms map Python floats to IEEE-754 > "double precision

Re: finding out the precision of floats

2007-02-25 Thread Arnaud Delobelle
On Feb 25, 3:59 pm, "Jerry Hill" <[EMAIL PROTECTED]> wrote: > On 25 Feb 2007 06:11:02 -0800, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > > > Moreover the reason I got interested in this is because I am creating > > a Dec class (decimal numbers) > > Are you familiar with Python's Decimal > librar

Re: finding out the precision of floats

2007-02-25 Thread Jerry Hill
On 25 Feb 2007 06:11:02 -0800, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > Moreover the reason I got interested in this is because I am creating > a Dec class (decimal numbers) Are you familiar with Python's Decimal library? http://docs.python.org/lib/module-decimal.html -- Jerry -- http://ma

Re: finding out the precision of floats

2007-02-25 Thread Arnaud Delobelle
On Feb 25, 1:31 pm, "John Machin" <[EMAIL PROTECTED]> wrote: > On Feb 25, 11:06 pm, "Arnaud Delobelle" <[EMAIL PROTECTED]> > wrote: [...] > Evidently not; here's some documentation we both need(ed) to read: > > http://docs.python.org/tut/node16.html Thanks for this link > I'm very curious to know

Re: finding out the precision of floats

2007-02-25 Thread John Machin
On Feb 25, 11:06 pm, "Arnaud Delobelle" <[EMAIL PROTECTED]> wrote: > On Feb 25, 11:20 am, "John Machin" <[EMAIL PROTECTED]> wrote: > [...] > > > I'm a little puzzled: > > > You don't seem to want a function that will tell you the actual number > > of significant decimal digits in a particular numbe

Re: finding out the precision of floats

2007-02-25 Thread Arnaud Delobelle
On Feb 25, 11:20 am, "John Machin" <[EMAIL PROTECTED]> wrote: [...] > I'm a little puzzled: > > You don't seem to want a function that will tell you the actual number > of significant decimal digits in a particular number e.g. > > nsig(12300.0) -> 3 > nsig(0.00123400) -> 4 > etc > > You appear to b

Re: finding out the precision of floats

2007-02-25 Thread John Machin
On Feb 25, 9:57 pm, "Arnaud Delobelle" <[EMAIL PROTECTED]> wrote: > Hi all, > > I want to know the precision (number of significant digits) of a float > in a platform-independent manner. I have scoured through the docs but > I can't find anything about it! > > At the moment I use this terrible sub

finding out the precision of floats

2007-02-25 Thread Arnaud Delobelle
Hi all, I want to know the precision (number of significant digits) of a float in a platform-independent manner. I have scoured through the docs but I can't find anything about it! At the moment I use this terrible substitute: FLOAT_PREC = repr(1.0/3).count('3') How can I do this properly or w