X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id BD7C3D1B4E1 for ; Tue, 28 Oct 2003 15:10:27 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 05188-05 for ; Tue, 28 Oct 2003 11:10:00 -0400 (AST) Received: from mail.deltav.hu (oldmail.deltav.hu [213.163.0.192]) by svr1.postgresql.org (Postfix) with ESMTP id 2FFA7D1B4F4 for ; Tue, 28 Oct 2003 11:09:55 -0400 (AST) Received: from fejleszt4 ([213.163.10.103]) by mail.deltav.hu (Netscape Messaging Server 3.6) with SMTP id AAA2694 for ; Tue, 28 Oct 2003 16:09:57 +0100 Message-ID: <072c01c39d65$65f83950$0403a8c0@fejleszt4> From: "=?iso-8859-2?B?U1rbQ1MgR+Fib3I=?=" To: Subject: numeric and float converts to int differently? Date: Tue, 28 Oct 2003 16:08:51 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200310/364 X-Sequence-Number: 15764 Dear Gurus, I'm using PostgreSQL 7.3.3. I was wondering if this is undefined, intentional or to be changed/fixed in the future. See the snippit at the end of this mail. QUESTION 1: Is it intentional that converting 0.5 to int4 - from numeric: rounds *away from* zero - from float: rounds *towards* zero (tried float4 and float8 too)? QUESTION 2: Is it safe to assume it won't change (haven't changed) in the upcoming versions? QUESTION 3: Is there a function or conversion method that converts 0.5 according to - mathematical rules (*up*) - accounting rules (*down*, at least here in Hungary)? TIA, G. ------------------------------- cut here ------------------------------- # select int4('0.5'::numeric); 1 # select int4('-0.5'::numeric); -1 # select int4('0.5'::float); 0 # select int4('-0.5'::float); 0 ------------------------------- cut here ------------------------------- What I would really like to see: # select round_math('0.5'); 1 # select round_math('-0.5'); 0 # select round_acct('0.5'); 0 # select round_acct('-0.5'); -1 ------------------------------- cut here -------------------------------