Re: [SQL] Decimal precsion?

From: wieck(at)debis(dot)com (Jan Wieck)
To: maillist(at)candle(dot)pha(dot)pa(dot)us (Bruce Momjian)
Cc: wieck(at)debis(dot)com, zot(at)zotconsulting(dot)com, pgsql-sql(at)postgreSQL(dot)org, jwieck(at)debis(dot)com
Subject: Re: [SQL] Decimal precsion?
Date: 1999-10-30 16:37:30
Message-ID: m11hbVS-0003kLC@orion.SAPserv.Hamburg.dsh.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

> > the column is declared as decimal with 4 digits after the
> > decimal point. Therefore, all values get rounded at the time
> > of INSERT/UPDATE. The above looks numerically right to me.
> >
> > Isn't that behaviour correct? Does the standard define
> > something else?
>
> OK, I wasn't sure on whether rounding was correct.
>
> However, the original message had DECIMAL(4,4) and he could insert 0.1,
> but not 0.0.

The rounding is of course correct. Rounding 0.1234567 first
to 0.123457 and then cutting of to 0.1234 is finally cutting,
not rounding, and totally braindead. You only have to look at
the digit after the last significant one. In this case we
have 4 significant digits, so we must look at digit 5,
nothing else. Thus 0.1234500 is 0.1235 while 0.1234499 is
0.1234 - end of story.

The other one, not beeing able to insert 0.0, is surely a
bug. Would you please put it onto the TODO?

Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#========================================= wieck(at)debis(dot)com (Jan Wieck) #

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Robert Forsman 1999-10-31 01:38:16 DISTINCT ON, when you want it, you're glad it's there
Previous Message Bruce Momjian 1999-10-30 15:55:20 Re: [SQL] Decimal precsion?