No execuse! My appologies for the cross posting. Your advice
is  well accepted.

Also thank you for your explaination regarding on my inquiry
as well.

Regards,


Pae

----- Original Message -----
From: "Benjamin Pflugmann" <[EMAIL PROTECTED]>
To: "Pae Choi" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Monday, November 18, 2002 11:49 AM
Subject: Re: [Feature or Bug] Data Types: DECIMAL and DOUBLE


> Hello.
>
> First, please stop cross posting. Pick one list and stay with it. Only
> post on another list if you get no reply for some time.
>
> Aside from that, one can argue if that belongs to the win32 list, but
> what has this to do with java at all?
>
> On Mon 2002-11-18 at 09:07:42 -0800, [EMAIL PROTECTED] wrote:
> > Say we create a table as follows:
> >
> > CREATE TABLE account (id INTEGER, balance DECIMAL(20, 2), col_double
> > DOUBLE(20,2));
> >
> > And we insert 6 rows as follows:
> >
> > INSERT INTO account (id, balance, col_double) VALUES (1,
> > 12345678901234567890.56, 12345678901234567890.56);
> > INSERT INTO account (id, balance, col_double) VALUES (2,
> > 1234567890123456789.56, 1234567890123456789.56);
> > INSERT INTO account (id, balance, col_double) VALUES (3,
> > 123456789012345678.56, 123456789012345678.56);
> > INSERT INTO account (id, balance, col_double) VALUES (4,
> > 12345678901234567.56, 12345678901234567.56);
> > INSERT INTO account (id, balance, col_double) VALUES (5,
> > 1234567890123456.56, 1234567890123456.56);
> > INSERT INTO account (id, balance, col_double) VALUES (6,
123456789012345.56,
> > 123456789012345.56);
> >
> > We I have from the table by executing a query as follows;
> >
> > SELECT * FROM account;
> >
> > ResultSet:
> > =======
> > id                            balance
col_double
> > 1    99999999999999999999.99    12345678901234567000.00
> > 2    12345678901234567800.00    12345678901234567800.00
> > 3       123456789012345680.00       123456789012345660.00
> > 4         12345678901234568.00        12345678901234568.00
> > 5          1234567890123456.50          1234567890123456.50
> > 6            123456789012345.56           123456789012345.56    <== Only
> > correct one
> >
> > Is this a feature or bug?
> >
> > Any comments? Thanks you.
>
> Note that double floating point values have only a precision of about
> 15-16 digits. That explains the behaviour you see with col_double.
>
> The behaviour you see with balance is because you use doubles to
> initialize the column. So the precision is already lost after parsing
> the insert. Using string constants instead of numbers should work, i.e.
>
> INSERT INTO account (balance) VALUES ("12345678901234567890.56")
>
> Except, of course, for the row with id=1 where the number is bigger
> than allowed by DECIMAL(20,2) and therefore set to the max value as
> explained in the manual.
>
> Regards,
>
> Benjamin.
>
>
> --
> [EMAIL PROTECTED]


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to