Received: from orion.SAPserv.Hamburg.dsh.de (Tpolaris2.sapham.debis.de [53.2.131.8]) by hub.org (8.9.3/8.9.3) with SMTP id MAA21022 for ; Sat, 30 Oct 1999 12:45:37 -0400 (EDT) (envelope-from wieck@debis.com) Received: by orion.SAPserv.Hamburg.dsh.de for pgsql-sql@postgreSQL.org id m11hbVS-0003kLC; Sat, 30 Oct 99 18:37 MET DST Message-Id: From: wieck@debis.com (Jan Wieck) Subject: Re: [SQL] Decimal precsion? To: maillist@candle.pha.pa.us (Bruce Momjian) Date: Sat, 30 Oct 1999 18:37:30 +0200 (MET DST) Cc: wieck@debis.com, zot@zotconsulting.com, pgsql-sql@postgreSQL.org, jwieck@debis.com Reply-To: wieck@debis.com (Jan Wieck) In-Reply-To: <199910301555.LAA04741@candle.pha.pa.us> from "Bruce Momjian" at Oct 30, 99 11:55:20 am X-Mailer: ELM [version 2.4 PL25] Content-Type: text > > 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@debis.com (Jan Wieck) #