Received: from sss.pgh.pa.us (sss.pgh.pa.us [209.114.132.154]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id eBJ12m630809 for ; Mon, 18 Dec 2000 20:02:48 -0500 (EST) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.1/8.11.1) with ESMTP id eBJ12nC02642; Mon, 18 Dec 2000 20:02:49 -0500 (EST) To: "He Weiping(Laser Henry)" cc: pgsql-docs@postgresql.org Subject: Re: some errors and/or bugs? In-reply-to: <3A3EB05E.C564D84A@zhengmai.com.cn> References: <3A3EB05E.C564D84A@zhengmai.com.cn> Comments: In-reply-to "He Weiping(Laser Henry)" message dated "Tue, 19 Dec 2000 08:48:30 +0800" Date: Mon, 18 Dec 2000 20:02:49 -0500 Message-ID: <2639.977187769@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200012/55 X-Sequence-Number: 102 "He Weiping(Laser Henry)" writes: > laser_zh=# select round(42.5); > round > ------- > 42 > (1 row) > > is it correct? I think result should be 43. It's correct, if the underlying float arithmetic is IEEE-compliant. Rounding for exact half-integral values is supposed to be "round to nearest even". So 42.5 goes to 42, but 43.5 goes to 44. I notice our NUMERIC rounding code does not do that ... perhaps it should. Also, the numeric round() function is just plain broken: regression=# select round(42.5::numeric); ERROR: Function 'numeric_round(numeric, int4)' does not exist Unable to identify a function that satisfies the given argument types You may need to add explicit typecasts regression=# select round(42.5::numeric,0); round ------- 43 (1 row) Looks like a silly oversight in the pg_proc entry for round(numeric). regards, tom lane