Re: BUG #14046: Bad mathematical rules for 0 cast

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Jarosław Stokłosa <jaroslaw(dot)stoklosa(at)nomino(dot)pl>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, John McKown <john(dot)archie(dot)mckown(at)gmail(dot)com>, "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #14046: Bad mathematical rules for 0 cast
Date: 2016-03-31 23:40:22
Message-ID: CAKFQuwZj8a0ONkngoXhM_O23NaWBGSM0nihPDZKuhshKz8F-_g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, Mar 31, 2016 at 12:49 AM, Jarosław Stokłosa <
jaroslaw(dot)stoklosa(at)nomino(dot)pl> wrote:

> You don't understand me. You give the examples differ than I - I've
> compared numbers with the same type, which are equal (IEEE 754, sign
> doesn't matter in this case for math equality). Cast to TEXT isn't able to
> turn off equality, in my opinion.
>

​-0 and +0 have distinct identities that are defined to compare as equal
when both values are represented as a floating point number. While it may
be your opinion that said equality should hold after converting -0 and +0
to textual representations it is impossible to simultaneously maintain
their distinct identities post-text conversion and have their text
representations compare as equal. PostgreSQL has chosen to treat their
identity characteristic as being primary and thus retains the + and - signs
when representing these values as text.

If there is anything more than your opinion of mathematical correctness
involved here it would be nice if you could share why it is you need the
float equality rules to continue to hold when two distinct floats are
represented as text.

In any case you can write a custom float-to-text function and use that
instead of "cast(float as text)"

David J.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Brahim EL ALLIOUI 2016-04-01 12:26:18 how to regenerate pg_control file ?
Previous Message Jarosław Stokłosa 2016-03-31 13:58:01 Re: BUG #14046: Bad mathematical rules for 0 cast