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.96) (envelope-from ) id 1wHKDk-0073qi-07 for pgsql-bugs@arkaria.postgresql.org; Mon, 27 Apr 2026 11:33:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wHKDj-00Dmkg-16 for pgsql-bugs@arkaria.postgresql.org; Mon, 27 Apr 2026 11:33:47 +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.96) (envelope-from ) id 1wHFiR-00CWKu-2u for pgsql-bugs@lists.postgresql.org; Mon, 27 Apr 2026 06:45:11 +0000 Received: from mahout.postgresql.org ([2001:4800:3e1:1::227]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wHFiN-00000003IBt-2jfN for pgsql-bugs@lists.postgresql.org; Mon, 27 Apr 2026 06:45:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=postgresql.org; s=20171124; h=Message-ID:Date:Reply-To:Cc:From:To:Subject: Content-Transfer-Encoding:MIME-Version:Content-Type:Sender:Content-ID: Content-Description:In-Reply-To:References; bh=OQxt5HFk3D8k7nZEh0GrGwDRpDW/Z576CHesm/X2FH8=; b=T8CAmAHYLmZHAPuKBO4m+f/SQj OSfX/fvSxvK89S76O1rDdyGzwsRTxbD7Y3jUJqxdaxeUPe+HiG+0n47PSCcNl1oLbJUAREzHC+m8z G4sXyzR97+58fTgi8+X+kO0QB9d9+bCYF1OxiGyN3Sl3vF12aXnja4wXNz6vg94MrQKFXrEWS1jqq rkUwmLazIAZuaGewwkuACtTLqJ3GpA1+XGE9nyIspYaPQy4ndJulU8CgVbwrbaIrzlemVdf4uDARb bpWoioDEBJeuaRWVepQmc1YHF0aFsh5R35IN/e+x1aOll4g9WbKbbg1UpKg6wyjfx/iXO4ZiDhqM3 S77AZg7Q==; Received: from wrigleys.postgresql.org ([2a02:16a8:dc51::60]) by mahout.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wHFiK-0097fk-2r for pgsql-bugs@lists.postgresql.org; Mon, 27 Apr 2026 06:45:06 +0000 Received: from localhost ([127.0.0.1] helo=wrigleys.postgresql.org) by wrigleys.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wHFiJ-002cSe-17 for pgsql-bugs@lists.postgresql.org; Mon, 27 Apr 2026 06:45:03 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #19467: Inconsistency in MOD() result involving POWER() and floating-point precision in PostgreSQL To: pgsql-bugs@lists.postgresql.org From: PG Bug reporting form Cc: fmusqlgen@163.com Reply-To: fmusqlgen@163.com, pgsql-bugs@lists.postgresql.org Date: Mon, 27 Apr 2026 06:44:56 +0000 Message-ID: <19467-b75f37ccc0b69261@postgresql.org> X-Auto-Response-Suppress: All Auto-Submitted: auto-generated List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk The following bug has been logged on the website: Bug reference: 19467 Logged by: Jasper Andrew Email address: fmusqlgen@163.com PostgreSQL version: 18.1 Operating system: Ubuntu 24.04 LTS x86_64 Description: =20 The following query produces inconsistent results across different database systems: ```SQL select mod(coalesce(pow(3.00,70.31),93.23),ceiling(sign(58.81))) from comments as ref_0; ``` # Observed Behavior - On MySQL, DuckDB, and MonetDB, the result is consistently: ```text mod ------ 0.0 0.0 0.0 0.0 (4 rows) ``` - On PostgreSQL, the same query returns: ```text mod ------ 0.41 0.41 0.41 0.41 (4 rows) ``` # Expected Behavior Given that: - sign(58.81) evaluates to 1 - ceiling(1) evaluates to 1 the expression simplifies to: - mod(pow(3.00, 70.31), 1) Mathematically, this corresponds to the fractional part of 3^70.31, which should be deterministic for a given evaluation strategy. However, different systems produce significantly different results: some return 0 only PostgreSQL returns 0.41 # Question Is this discrepancy expected due to differences in floating-point evaluation and implementation of functions such as: - POWER() / pow() - MOD() - implicit type handling (e.g., double precision vs numeric) Or could this indicate a potential inconsistency in how PostgreSQL evaluates floating-point expressions compared to other systems?