pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: 798604270@qq.com
Subject: BUG #18976: -0.0 with float8 will be transformed to 0 in prepare statement but not in normal execution
Date: Thu, 03 Jul 2025 03:03:05 +0000
Message-ID: <18976-c1bc92542b90e5e6@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      18976
Logged by:          Chi Zhang
Email address:      798604270@qq.com
PostgreSQL version: 18beta1
Operating system:   Ubuntu 24.04 and docker
Description:        

The value -0.0 with float8 is transformed to 0 in prepared statements but
remains -0 in normal execution. Although 0 and -0 are numerically equal,
this discrepancy can lead to subtle bugs in certain cases—for example, when
the value is cast to a VARCHAR, as illustrated below.
```
PREPARE prepare_query (float8) AS SELECT CAST($1 AS VARCHAR) =
CAST(-0.0::float8 AS VARCHAR);
EXECUTE prepare_query(-0.0); -- f
```



view thread (5+ messages)  latest in thread

Message-ID: <18976-c1bc92542b90e5e6@postgresql.org>
Permalink:  ../18976-c1bc92542b90e5e6@postgresql.org/
Also on:    postgresql.org/message-id/18976-c1bc92542b90e5e6@postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, 798604270@qq.com
  Subject: Re: BUG #18976: -0.0 with float8 will be transformed to 0 in prepare statement but not in normal execution
  In-Reply-To: <18976-c1bc92542b90e5e6@postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox