Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rChr8-00Gwrx-9o for pgsql-bugs@arkaria.postgresql.org; Mon, 11 Dec 2023 15:06:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rChr4-00EvjE-9U for pgsql-bugs@arkaria.postgresql.org; Mon, 11 Dec 2023 15:05:58 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rChr4-00Evfs-03 for pgsql-bugs@lists.postgresql.org; Mon, 11 Dec 2023 15:05:58 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rChr1-00BOin-Kr for pgsql-bugs@lists.postgresql.org; Mon, 11 Dec 2023 15:05:57 +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 3BBF5raI2171715; Mon, 11 Dec 2023 10:05:53 -0500 From: Tom Lane To: Michael Paquier cc: exclusion@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18240: Undefined behaviour in cash_mul_flt8() and friends In-reply-to: References: <18240-c5da758d7dc1ecf0@postgresql.org> Comments: In-reply-to Michael Paquier message dated "Mon, 11 Dec 2023 11:22:23 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2171713.1702307153.1@sss.pgh.pa.us> Date: Mon, 11 Dec 2023 10:05:53 -0500 Message-ID: <2171714.1702307153@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Michael Paquier writes: > On Mon, Dec 11, 2023 at 06:00:02AM +0000, PG Bug reporting form wrote: >> The following multiplication: >> SELECT 1_000_000_000::money * 1_000_000_000::float8; >> gives the incorrect result: >> -$92,233,720,368,547,758.08 > Yep, good catch. Reproduced here. Yeah, approximately none of cash.c pays any attention to the risks of overflow/underflow. Improving that situation would be a good finger exercise for some aspiring hacker, perhaps. Although I bet somebody will ask again why it is that we continue to support the money type. regards, tom lane