Re: strings (dollar.cents) into floats

2007-08-31 Thread Steve Holden
Ben Finney wrote: Wildemar Wildenburger [EMAIL PROTECTED] writes: But what use is there for floats, then? When is it OK to use them? When one is willing to sacrifice decimal precision for speed of calculation, and doesn't need the numbers to stay precise. E.g. when performing millions of

Re: strings (dollar.cents) into floats

2007-08-31 Thread sturlamolden
On 31 Aug, 02:12, Wildemar Wildenburger [EMAIL PROTECTED] wrote: I've heard (ok, read) that several times now and I understand the argument. But what use is there for floats, then? When is it OK to use them? There are fractions that can be exactly represented by floats that cannot be exactly

Re: strings (dollar.cents) into floats

2007-08-31 Thread Steve Holden
sturlamolden wrote: On 31 Aug, 02:12, Wildemar Wildenburger [EMAIL PROTECTED] wrote: I've heard (ok, read) that several times now and I understand the argument. But what use is there for floats, then? When is it OK to use them? There are fractions that can be exactly represented by floats

Re: strings (dollar.cents) into floats

2007-08-31 Thread Chris Mellon
On 8/31/07, Steve Holden [EMAIL PROTECTED] wrote: sturlamolden wrote: On 31 Aug, 02:12, Wildemar Wildenburger [EMAIL PROTECTED] wrote: I've heard (ok, read) that several times now and I understand the argument. But what use is there for floats, then? When is it OK to use them?

Re: strings (dollar.cents) into floats

2007-08-31 Thread MRAB
On Aug 31, 5:28 pm, Chris Mellon [EMAIL PROTECTED] wrote: On 8/31/07, Steve Holden [EMAIL PROTECTED] wrote: sturlamolden wrote: On 31 Aug, 02:12, Wildemar Wildenburger [EMAIL PROTECTED] wrote: I've heard (ok, read) that several times now and I understand the argument. But what use

Re: strings (dollar.cents) into floats

2007-08-31 Thread David H Wild
In article [EMAIL PROTECTED], Chris Mellon [EMAIL PROTECTED] wrote: I believe that to the degree that real accounting was done in those currencies it did in fact use non-decimal bases. Just as people don't use decimal time values (except us crazy computer folk), you're write 1 pound 4

Re: strings (dollar.cents) into floats

2007-08-31 Thread Steve Holden
Chris Mellon wrote: On 8/31/07, Steve Holden [EMAIL PROTECTED] wrote: sturlamolden wrote: On 31 Aug, 02:12, Wildemar Wildenburger [EMAIL PROTECTED] wrote: I've heard (ok, read) that several times now and I understand the argument. But what use is there for floats, then? When is it OK to use

Re: strings (dollar.cents) into floats

2007-08-31 Thread MRAB
On Aug 31, 5:39 pm, David H Wild [EMAIL PROTECTED] wrote: In article [EMAIL PROTECTED], Chris Mellon [EMAIL PROTECTED] wrote: I believe that to the degree that real accounting was done in those currencies it did in fact use non-decimal bases. Just as people don't use decimal time

Re: strings (dollar.cents) into floats

2007-08-31 Thread Steve Holden
MRAB wrote: On Aug 31, 5:39 pm, David H Wild [EMAIL PROTECTED] wrote: In article [EMAIL PROTECTED], Chris Mellon [EMAIL PROTECTED] wrote: I believe that to the degree that real accounting was done in those currencies it did in fact use non-decimal bases. Just as people don't use decimal

Re: strings (dollar.cents) into floats

2007-08-31 Thread David H Wild
In article [EMAIL PROTECTED], MRAB [EMAIL PROTECTED] wrote: When I worked on the British Railways National Payroll system, about 35 years ago, we, in common with many large users, wrote our system to deal with integer amounts of pennies, and converted to pounds, shillings and pence in

Re: strings (dollar.cents) into floats

2007-08-31 Thread John Machin
On Sep 1, 4:51 am, Dennis Lee Bieber [EMAIL PROTECTED] wrote: On Fri, 31 Aug 2007 12:06:49 -0400, Steve Holden [EMAIL PROTECTED] declaimed the following in comp.lang.python: That last sentence is patent nonsense, and completely untrue. Many satisfactory financial applications have been

Re: strings (dollar.cents) into floats

2007-08-31 Thread John Machin
On Sep 1, 4:58 am, MRAB [EMAIL PROTECTED] wrote: On Aug 31, 5:39 pm, David H Wild [EMAIL PROTECTED] wrote: In article [EMAIL PROTECTED], Chris Mellon [EMAIL PROTECTED] wrote: I believe that to the degree that real accounting was done in those currencies it did in fact use

Re: strings (dollar.cents) into floats

2007-08-31 Thread Lawrence D'Oliveiro
In message [EMAIL PROTECTED], sturlamolden wrote: There are fractions that can be exactly represented by floats that cannot be exactly represented by decimals. There are no such. -- http://mail.python.org/mailman/listinfo/python-list

Re: strings (dollar.cents) into floats

2007-08-31 Thread Lawrence D'Oliveiro
In message [EMAIL PROTECTED], Wildemar Wildenburger wrote: But what use is there for floats, then? When is it OK to use them? Floating-point numbers are useful when you have to deal with very large and very small amounts at the same time. In using them, you must understand something about how

Re: strings (dollar.cents) into floats

2007-08-31 Thread Grant Edwards
On 2007-09-01, Lawrence D'Oliveiro [EMAIL PROTECTED] wrote: In message [EMAIL PROTECTED], sturlamolden wrote: There are fractions that can be exactly represented by floats that cannot be exactly represented by decimals. There are no such. In that statement does float mean finite-length

strings (dollar.cents) into floats

2007-08-30 Thread luca bertini
Hi, i have strings which look like money values (ie 34.45) is there a way to convert them into float variables? everytime i try I get this error: numb = float(my_line) ValueError: empty string for float() here's the code import sys import re for line in sys.stdin.readlines():

Re: strings (dollar.cents) into floats

2007-08-30 Thread Marshall T. Vandegrift
luca bertini [EMAIL PROTECTED] writes: i have strings which look like money values (ie 34.45) is there a way to convert them into float variables? everytime i try I get this error: numb = float(my_line) ValueError: empty string for float() You actually have problems here -- the

Re: strings (dollar.cents) into floats

2007-08-30 Thread Gary Herron
luca bertini wrote: Hi, i have strings which look like money values (ie 34.45) is there a way to convert them into float variables? everytime i try I get this error: numb = float(my_line) ValueError: empty string for float() here's the code import sys import re for

Re: strings (dollar.cents) into floats

2007-08-30 Thread J. Cliff Dyer
Gary Herron wrote: luca bertini wrote: Hi, i have strings which look like money values (ie 34.45) is there a way to convert them into float variables? everytime i try I get this error: numb = float(my_line) ValueError: empty string for float() here's the code import sys

Re: strings (dollar.cents) into floats

2007-08-30 Thread Ben Finney
luca bertini [EMAIL PROTECTED] writes: i have strings which look like money values (ie 34.45) is there a way to convert them into float variables? You most likely do *not* want floating-point numbers for currency, since they rely on the operating system's binary floating point support which

Re: strings (dollar.cents) into floats

2007-08-30 Thread Wildemar Wildenburger
Ben Finney wrote: You most likely do *not* want floating-point numbers for currency, since they rely on the operating system's binary floating point support which cannot accurately represent decimal fractions. I've heard (ok, read) that several times now and I understand the argument. But

Re: strings (dollar.cents) into floats

2007-08-30 Thread Robert Kern
Wildemar Wildenburger wrote: Ben Finney wrote: You most likely do *not* want floating-point numbers for currency, since they rely on the operating system's binary floating point support which cannot accurately represent decimal fractions. I've heard (ok, read) that several times now and I

Re: strings (dollar.cents) into floats

2007-08-30 Thread Ben Finney
Wildemar Wildenburger [EMAIL PROTECTED] writes: But what use is there for floats, then? When is it OK to use them? When one is willing to sacrifice decimal precision for speed of calculation, and doesn't need the numbers to stay precise. E.g. when performing millions of calculations on