Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ogoUb-0004UV-82 for pgsql-committers@arkaria.postgresql.org; Fri, 07 Oct 2022 14:38:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ogoUZ-0003es-Qi for pgsql-committers@arkaria.postgresql.org; Fri, 07 Oct 2022 14:38:23 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ogoUZ-0003ej-Ji for pgsql-committers@lists.postgresql.org; Fri, 07 Oct 2022 14:38:23 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ogoUX-0008QX-37 for pgsql-committers@lists.postgresql.org; Fri, 07 Oct 2022 14:38:23 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 297EcGIX3155927; Fri, 7 Oct 2022 10:38:16 -0400 From: Tom Lane To: Peter Eisentraut cc: pgsql-committers@lists.postgresql.org Subject: Re: pgsql: Remove unnecessary uses of Abs() In-reply-to: References: Comments: In-reply-to Peter Eisentraut message dated "Fri, 07 Oct 2022 11:38:05 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3155925.1665153496.1@sss.pgh.pa.us> Date: Fri, 07 Oct 2022 10:38:16 -0400 Message-ID: <3155926.1665153496@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Peter Eisentraut writes: > Remove unnecessary uses of Abs() Re-reading this, I noticed something that's probably not good: in ecpg/pgtypeslib/interval.c you did - sprintf(cp, "%02d.%0*d", abs(sec), precision, (int) Abs(fsec)); + sprintf(cp, "%02d.%0*d", abs(sec), precision, abs(fsec)); (in 2 places). I think this has possibly broken the direction of rounding for negative values, because we'll now truncate to integer before changing sign. Maybe it's okay but you have to make assumptions about what it'll do. Safer would have been + sprintf(cp, "%02d.%0*d", abs(sec), precision, (int) fabs(fsec)); There is similar-looking coding in remove_gene(), but I didn't check the data type involved. regards, tom lane