[sqlite] Adding and subtracting decimals is not accurate

2004-06-04 Thread Randall Fox
After reading the FAQ and type information over, I went and tried the following: CREATE TABLE M (A numeric, B text); INSERT INTO M VALUES (1.2); INSERT INTO M VALUES (1.2); INSERT INTO M VALUES (1.2); . . ; did this about 45 times . . SELECT SUM(A) FROM M; result was 52.8001 Defining th

Re: [sqlite] Adding and subtracting decimals is not accurate

2004-06-04 Thread Gerry Snyder
Randall Fox wrote: After reading the FAQ and type information over, I went and tried the following: CREATE TABLE M (A numeric, B text); INSERT INTO M VALUES (1.2); INSERT INTO M VALUES (1.2); INSERT INTO M VALUES (1.2); . . ; did this about 45 times . . SELECT SUM(A) FROM M; result was 52.8000

Re: [sqlite] Adding and subtracting decimals is not accurate

2004-06-04 Thread Mitchell Vincent
Welcome to the wonderful world of floating point numbers :-) I always store money values as cents (or as integers, what ever your currency might call it) and move the decimal to format for display.. Randall Fox wrote: After reading the FAQ and type information over, I went and tried the following

Re: [sqlite] Adding and subtracting decimals is not accurate

2004-06-05 Thread Randall Fox
On Fri, 04 Jun 2004 20:39:45 -0700, you wrote: >You mean like rounding once in a while to the number of significant >decimal places? Once every few billion additions like those above should >suffice. That defeats the purpose of being able to "SELECT SUM(X) FROM ... " The aggregate query sum(x)

Re: [sqlite] Adding and subtracting decimals is not accurate

2004-06-05 Thread Randall Fox
On Fri, 04 Jun 2004 23:46:06 -0400, you wrote: >Welcome to the wonderful world of floating point numbers :-) > >I always store money values as cents (or as integers, what ever your >currency might call it) and move the decimal to format for display.. Yes, I took a closer look at floating point a

Re: [sqlite] Adding and subtracting decimals is not accurate

2004-06-05 Thread D. Richard Hipp
Randall Fox wrote: > On Fri, 04 Jun 2004 23:46:06 -0400, you wrote: > > I was worried that once the number got put into a floating point notation, > the error would still creep up... > The value 1.2 cannot be represented exactly in a (finite-length) binary number. On my machine, 1.2 gets stored as

RE: [sqlite] Adding and subtracting decimals is not accurate

2004-06-05 Thread Fred Williams
for the reasons you suffer from.) Floating point is damn near useless IMHO. Fred > -Original Message- > From: Randall Fox [mailto:[EMAIL PROTECTED] > Sent: Saturday, June 05, 2004 5:20 AM > To: [EMAIL PROTECTED] > Subject: Re: [sqlite] Adding and subtracting decimals

Re: [sqlite] Adding and subtracting decimals is not accurate

2004-06-06 Thread Raymond Irving
Hi, Is this a problem with all database systems or is it only unique to SQLite? __ Raymond Irving "D. Richard Hipp" <[EMAIL PROTECTED]> wrote: The value 1.2 cannot be represented exactly in a (finite-length) binary number. On my machine, 1.2 gets stored as 1.1999555910790149937383

Re: [sqlite] Adding and subtracting decimals is not accurate

2004-06-07 Thread Christian Smith
On Sun, 6 Jun 2004, Raymond Irving wrote: >Hi, > >Is this a problem with all database systems or is it only unique to SQLite? Most database systems have a seperate money type precisely for this problem, which is often BCD to allow arbitrary length values. Rounding errors are simply not an option

Re: [sqlite] Adding and subtracting decimals is not accurate

2004-06-07 Thread William Trenker
On Mon, 7 Jun 2004 12:31:37 +0100 (BST), Christian Smith <[EMAIL PROTECTED]> wrote: > > Most database systems have a seperate money type precisely for this > problem, which is often BCD to allow arbitrary length values. Rounding > errors are simply not an option for financial institutions. Intern