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 1ogrZH-0001ZZ-Qz for pgsql-committers@arkaria.postgresql.org; Fri, 07 Oct 2022 17:55:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ogrZG-0005yU-M5 for pgsql-committers@arkaria.postgresql.org; Fri, 07 Oct 2022 17:55:26 +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 1ogrZG-0005yL-EY for pgsql-committers@lists.postgresql.org; Fri, 07 Oct 2022 17:55:26 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ogrZC-0001nO-3U for pgsql-committers@lists.postgresql.org; Fri, 07 Oct 2022 17:55:26 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 409535C01AA; Fri, 7 Oct 2022 13:55:20 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Fri, 07 Oct 2022 13:55:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1665165320; x= 1665251720; bh=3v8/QuQl8YBYRkIwMljdzUbZzic+QGOCoY5mT1T7YA8=; b=h kf34m3GRt2vKKUV5w8Jas31iEgBqTZIm8JqTwjH6ymrSi3U4G+z8b9dt4slI6TU8 sgta5jYyXWcp9uDQpB66VcGUYBDxacGYtAqDqobxsSF1RrtI1Hi0OFR9Ut/7R4Y+ h7AERE9lKx9t68QchrnwQkLUjfMnEnPqLSmy9AYPAWx4WtlMdHZE5vUve37vT1lN wjxB24AQLPYEDYPNurrldMMedS3H63btsVYI5WUVxjWdcAXlX2ehKOxnKIRqQOEU VlpJWVbxEr4GEF6axcDwCrI9D1gjQms/Gxrbp8KoOPXi34ZsU+8F2RNqqVU7n218 MaKE4ZgUzFsCK9ZEkjfYg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeeijedguddulecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepkfffgggfuffvvehfhfgjtgfgse htjeertddtfeejnecuhfhrohhmpefrvghtvghrucfgihhsvghnthhrrghuthcuoehpvght vghrrdgvihhsvghnthhrrghuthesvghnthgvrhhprhhishgvuggsrdgtohhmqeenucggtf frrghtthgvrhhnpeehleffgeegudejteeihfelteduvdeifffhffdvjedvffegjeekudel udehudeifeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehpvghtvghrrdgvihhsvghnthhrrghuthesvghnthgvrhhprhhishgvuggsrdgtohhm X-ME-Proxy: Feedback-ID: i131946ab:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 7 Oct 2022 13:55:18 -0400 (EDT) Message-ID: <11e02543-b480-cb6b-1271-6438841b1b8a@enterprisedb.com> Date: Fri, 7 Oct 2022 19:55:17 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.3.1 Subject: Re: pgsql: Remove unnecessary uses of Abs() Content-Language: en-US To: Tom Lane Cc: pgsql-committers@lists.postgresql.org References: <3155926.1665153496@sss.pgh.pa.us> From: Peter Eisentraut In-Reply-To: <3155926.1665153496@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 07.10.22 16:38, Tom Lane wrote: > 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)); fsec is of type fsec_t, which is int32. So these expressions are integer all the way through. > There is similar-looking coding in remove_gene(), but I didn't check > the data type involved. There, the type "Gene" is int, so also no floats involved AFAICT.