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

From: John McKown <john(dot)archie(dot)mckown(at)gmail(dot)com>
To: jaroslaw(dot)stoklosa(at)nomino(dot)pl
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #14046: Bad mathematical rules for 0 cast
Date: 2016-03-25 13:32:19
Message-ID: CAAJSdjhfjrtzPjtNbf=qGeD1o+cwxfYLo_9nB2_AsVODQB7Gog@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Fri, Mar 25, 2016 at 3:56 AM, <jaroslaw(dot)stoklosa(at)nomino(dot)pl> wrote:

> The following bug has been logged on the website:
>
> Bug reference: 14046
> Logged by: Jarosław Stokłosa
> Email address: jaroslaw(dot)stoklosa(at)nomino(dot)pl
> PostgreSQL version: 9.4.5
> Operating system: x86_64-redhat-linux-gnu
> Description:
>
> Below query should return 2 times TRUE.
>
> SELECT cast('+0' as FLOAT) = cast('-0' as FLOAT), cast('+0' as FLOAT)::TEXT
> = cast('-0' as FLOAT)::TEXT
>
> +0 and -0 should be casted to +0 or 0.
>

​I humbly disagree with you. PostgreSQL use IEEE 754 for floating point
(mainly because that is what most - not all - computers today use). IEEE
754 distinguishes +0 (or just 0) from -0. cast('-0' as FLOAT) results in an
IEEE 754 negative zero. Which is not identically equal to a positive zero.
The case to TEXT should, and does, preserve this non-identical difference. ​

>
> Regards
>
>
>
> --
> Sent via pgsql-bugs mailing list (pgsql-bugs(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-bugs
>

--
How many surrealists does it take to screw in a lightbulb? One to hold the
giraffe and one to fill the bathtub with brightly colored power tools.

Maranatha! <><
John McKown

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2016-03-25 13:39:34 Re: BUG #14046: Bad mathematical rules for 0 cast
Previous Message Thom Brown 2016-03-25 13:25:41 Re: Breakage with VACUUM ANALYSE + partitions