Re: Decimal() instead of float?

2006-11-17 Thread Tim Peters
[Michael B. Trausch] >> Let's say that I want to work with the latitude 33.6907570. In Python, >> that number > can not be stored exactly without the aid of >> decimal.Decimal(). >> >> >>> 33.6907570 >> 33.6907568 >> >>> >> >> As you can see, it loses accuracy after the 6th decimal place.

Re: Decimal() instead of float?

2006-11-17 Thread Robert Kern
Robert Kern wrote: > Fredrik Lundh wrote: >> Terry Reedy wrote: >> >>> This is far more accurate than any measured latitude could be. >> you're saying that we don't measure geographical positions on an atomic >> scale? ;-) >> >> (it's too late for serious calculations, but I'd guess we're talking

Re: Decimal() instead of float?

2006-11-17 Thread Robert Kern
Fredrik Lundh wrote: > Terry Reedy wrote: > >> This is far more accurate than any measured latitude could be. > > you're saying that we don't measure geographical positions on an atomic > scale? ;-) > > (it's too late for serious calculations, but I'd guess we're talking > Ångströms here, righ

Re: Decimal() instead of float?

2006-11-17 Thread Fredrik Lundh
Terry Reedy wrote: > This is far more accurate than any measured latitude could be. you're saying that we don't measure geographical positions on an atomic scale? ;-) (it's too late for serious calculations, but I'd guess we're talking Ångströms here, right?) -- http://mail.python.org/mail

Re: Decimal() instead of float?

2006-11-17 Thread Terry Reedy
"Michael B. Trausch" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Let's say that I want to work with the latitude 33.6907570. In Python, > that number > can not be stored exactly without the aid of > decimal.Decimal(). > >>> 33.6907570 > 33.6907568 > >>> > As you can

Re: Decimal() instead of float?

2006-11-17 Thread Ron Adam
Michael B. Trausch wrote: > On Fri, 2006-11-17 at 21:25 +0100, Fredrik Lundh wrote: >> > Some of the lat/long pairs that I have used seem to come out fine, but >> > some do not. Because the mathmatics used with them involve complex >> > equations when determining distance and the like, any error

Re: Decimal() instead of float?

2006-11-17 Thread Fredrik Lundh
Michael B. Trausch wrote: > Sure, I do. Let's say that I want to work with the latitude > 33.6907570. In Python, that number can not be stored exactly without > the aid of decimal.Decimal(). > > >>> 33.6907570 > 33.6907568 > >>> > > As you can see, it loses accuracy after the 6th d

Re: Decimal() instead of float?

2006-11-17 Thread Carsten Haese
On Fri, 2006-11-17 at 16:51 -0500, Michael B. Trausch wrote: > On Fri, 2006-11-17 at 21:25 +0100, Fredrik Lundh wrote: > > > Some of the lat/long pairs that I have used seem to come out fine, but > > > some do not. Because the mathmatics used with them involve complex > > > equations when deter

Re: Decimal() instead of float?

2006-11-17 Thread Robert Kern
Michael B. Trausch wrote: > Perhaps you should not make assumptions; I am sure that you have heard > what they do at some point before. While *some* of the error doesn't > propagate as expected (which is actually a problem in itself—equations > no longer make sense if they are not mathematically b

Re: Decimal() instead of float?

2006-11-17 Thread Carsten Haese
On Fri, 2006-11-17 at 16:51 -0500, Michael B. Trausch wrote: > [...] > Let's say that I want to work with the latitude 33.6907570. In > Python, that number can not be stored exactly without the aid of > decimal.Decimal(). > > >>> 33.6907570 > 33.6907568 You say that like it's Python's fa

Re: Decimal() instead of float?

2006-11-17 Thread Michael B. Trausch
On Fri, 2006-11-17 at 21:25 +0100, Fredrik Lundh wrote: > > Some of the lat/long pairs that I have used seem to come out fine, but > > some do not. Because the mathmatics used with them involve complex > > equations when determining distance and the like, any error gets > > massively compounde

Re: Decimal() instead of float?

2006-11-17 Thread Fredrik Lundh
Michael B. Trausch wrote: > I don't have (so far as I know) a 64-bit float available to me. as mentioned in the documentation, Python's "float" datatype is implemented C doubles, which is 64-bit IEEE on all major platforms. > Some of the lat/long pairs that I have used seem to come out fine, bu

Re: Decimal() instead of float?

2006-11-17 Thread Robert Kern
Michael B. Trausch wrote: > I don't have (so far as I know) a 64-bit float available to me. Yes, you do: the regular Python float type. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as th

Re: Decimal() instead of float?

2006-11-17 Thread Michael B. Trausch
-point but it > > certainly wouldn't be trivial: consider the use of C language libraries > > that know nothing of Python's decimal representation. > > judging from the various decimal FAQ:s, I think it's a bit naive to > think that using Decimal instead

Re: Decimal() instead of float?

2006-11-16 Thread Gabriel Genellina
At Thursday 16/11/2006 04:40, Fredrik Lundh wrote: internal rowid's are best treated as pointers, though. they're more like memory addresses than labels. (from a design perspective, it's not entirely obvious that it's a good idea to use rowid's to point *into* the database from the outside, bu

Re: Decimal() instead of float?

2006-11-16 Thread Steve Holden
Paul Rubin wrote: > Steve Holden <[EMAIL PROTECTED]> writes: >> Unfortunately some applications are getting such large tables that a >> 32-bit field is insufficient to enumerate all existing and deleted >> rows. Then you have to start keeping tables of unused primary keys. > > Please tell me that'

Re: Decimal() instead of float?

2006-11-16 Thread Paul Rubin
Steve Holden <[EMAIL PROTECTED]> writes: > Unfortunately some applications are getting such large tables that a > 32-bit field is insufficient to enumerate all existing and deleted > rows. Then you have to start keeping tables of unused primary keys. Please tell me that's not from some Kafka night

Re: Decimal() instead of float?

2006-11-16 Thread Steve Holden
Terry Reedy wrote: > "John Salerno" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> John Machin wrote: >> >>> Here in Austraila, (I expect this is common to most countries), there >>> are people who are utterly clueless about elementary data model rules, >>> like identification "n

Re: Decimal() instead of float?

2006-11-15 Thread Fredrik Lundh
Hendrik van Rooyen wrote: > Nothing wrong with doing that - its not as if you are going to arithmetic with > them - adding my id to yours is generally not very useful... internal rowid's are best treated as pointers, though. they're more like memory addresses than labels. (from a design perspe

Re: Decimal() instead of float?

2006-11-15 Thread Hendrik van Rooyen
"John Salerno" <[EMAIL PROTECTED]> wrote: > John Machin wrote: > > > Here in Austraila, (I expect this is common to most countries), there > > are people who are utterly clueless about elementary data model rules, > > like identification "numbers" should be kept as strings. > > Do you mean that I

Re: Decimal() instead of float?

2006-11-15 Thread Hendrik van Rooyen
"Fredrik Lundh" <[EMAIL PROTECTED]> wrote: > .. and seriously, under- > standing the various aspects of floats and decimals is utterly trivial > compared to all the nearly-magical things you need to understand to be > able to do geographical calculations at a sub-millimeter scale. heck, >

Re: Decimal() instead of float?

2006-11-15 Thread John Machin
On 16/11/2006 8:57 AM, Terry Reedy wrote: > "John Salerno" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> John Machin wrote: >> >>> Here in Austraila, (I expect this is common to most countries), there >>> are people who are utterly clueless about elementary data model rules, >>>

Re: Decimal() instead of float?

2006-11-15 Thread Aahz
In article <[EMAIL PROTECTED]>, John Salerno <[EMAIL PROTECTED]> wrote: >John Machin wrote: >> >> Here in Austraila, (I expect this is common to most countries), there >> are people who are utterly clueless about elementary data model rules, >> like identification "numbers" should be kept as strin

Re: Decimal() instead of float?

2006-11-15 Thread Terry Reedy
"John Salerno" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > John Machin wrote: > >> Here in Austraila, (I expect this is common to most countries), there >> are people who are utterly clueless about elementary data model rules, >> like identification "numbers" should be kept as s

Re: Decimal() instead of float?

2006-11-15 Thread John Salerno
John Machin wrote: > Here in Austraila, (I expect this is common to most countries), there > are people who are utterly clueless about elementary data model rules, > like identification "numbers" should be kept as strings. Do you mean that ID numbers that serve as a primary key in a database sho

Re: Decimal() instead of float?

2006-11-15 Thread Fredrik Lundh
; that know nothing of Python's decimal representation. judging from the various decimal FAQ:s, I think it's a bit naive to think that using Decimal instead of float would somehow make everything "just work": http://www2.hursley.ibm.com/decimal/decifaq.html http://effbot.org/

Re: Decimal() instead of float?

2006-11-14 Thread Steve Holden
Michael B. Trausch wrote: > On Mon, 2006-11-13 at 03:45 -0600, Steve Holden wrote: >> Michael B. Trausch wrote: >> > Is there a way to use Decimal() by default in Python instead of float? >> >> No. You'll just have to be explicit. >> > > That's kinda what I figured. :-( > > It /would/ be nice

Re: Decimal() instead of float?

2006-11-13 Thread Steve Holden
Michael B. Trausch wrote: > Is there a way to use Decimal() by default in Python instead of float? No. You'll just have to be explicit. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://hol

Re: Decimal() instead of float?

2006-11-12 Thread Steven D'Aprano
On Sun, 12 Nov 2006 20:38:31 +1100, Ben Finney wrote: > But you try to tell people overseas about this legislation, and they > just don't believe you. Ha! You were lucky. When I was a lad, we had to write our postcodes on envelopes in balanced ternary. -- Steven. -- http://mail.python.org/ma

Re: Decimal() instead of float?

2006-11-12 Thread John Machin
Steven D'Aprano wrote: > On Sun, 12 Nov 2006 02:31:04 +0100, Fredrik Lundh wrote: > > >> For example, I have a ZIP code > >> database that can do some processing on its numbers, and the numbers are > >> stored as floating point values (exactly) but Python doesn't get them > >> right > > > > sounds

Re: Decimal() instead of float?

2006-11-12 Thread Ben Finney
"Steven D'Aprano" <[EMAIL PROTECTED]> writes: > On Sun, 12 Nov 2006 02:31:04 +0100, Fredrik Lundh wrote: > > (who uses fractional ZIP codes, btw?) > > Well, I can't speak for Americans, but here in Australia we > typically give our post codes to six decimal places: > > Melbourne 3000.00 > Brun

Re: Decimal() instead of float?

2006-11-11 Thread Steven D'Aprano
On Sun, 12 Nov 2006 02:31:04 +0100, Fredrik Lundh wrote: >> For example, I have a ZIP code >> database that can do some processing on its numbers, and the numbers are >> stored as floating point values (exactly) but Python doesn't get them >> right > > sounds odd. are you sure you don't mean

Re: Decimal() instead of float?

2006-11-11 Thread Fredrik Lundh
Michael B. Trausch wrote: > Is there a way to use Decimal() by default in Python instead of float? nope. > For example, I have a ZIP code > database that can do some processing on its numbers, and the numbers are > stored as floating point values (exactly) but Python doesn't get them > righ

Decimal() instead of float?

2006-11-11 Thread Michael B. Trausch
Is there a way to use Decimal() by default in Python instead of float?  I've no use for the float type, and I have some stuff that would require Decimal(), but it is kind of a pain to try and cast things all over the place all the time.  Float is just way too inexact for me. I am searching aro