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

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: BUG #14046: Bad mathematical rules for 0 cast
Дата
Msg-id CAKFQuwbmR06hJZ5CEZbUPsMXP_KP0rOo=9n=UPX8XTsmk9vtCg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: BUG #14046: Bad mathematical rules for 0 cast  (Jarosław Stokłosa <jaroslaw.stoklosa@nomino.pl>)
Ответы Re: BUG #14046: Bad mathematical rules for 0 cast  (Jarosław Stokłosa <jaroslaw.stoklosa@nomino.pl>)
Re: BUG #14046: Bad mathematical rules for 0 cast  (Jarosław Stokłosa <jaroslaw.stoklosa@nomino.pl>)
Список pgsql-bugs
On Tue, Mar 29, 2016 at 11:55 PM, Jaros=C5=82aw Stok=C5=82osa <
jaroslaw.stoklosa@nomino.pl> wrote:

>
> W dniu 25/03/2016 o 14:32, John McKown pisze:
>
> On Fri, Mar 25, 2016 at 3:56 AM, < <jaroslaw.stoklosa@nomino.pl>
> jaroslaw.stoklosa@nomino.pl> wrote:
>
>> The following bug has been logged on the website:
>>
>> Bug reference:      14046
>> Logged by:          Jaros=C5=82aw Stok=C5=82osa
>> Email address:      jaroslaw.stoklosa@nomino.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) =3D cast('-0' as FLOAT), cast('+0' as
>> FLOAT)::TEXT
>> =3D cast('-0' as FLOAT)::TEXT
>>
>> +0 and -0 should be casted to +0 or 0.
>>
>
=E2=80=8BHow would you propose to implement this "or"?=E2=80=8B


> =E2=80=8BI 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=
. =E2=80=8B
>
>
> I'm disagee with you. PostgreSQL don't distinguish +0 from -0 because
> cast('+0' as FLOAT) =3D cast('-0' as FLOAT) equals to TRUE. This is math
> rules. So case to float then to text shoud, and doesn't, preserve the
> equality. IEEE754 describes storage numbers in computer's memory but
> doesn't turn off math comparation rules.
>

Agreed.  It is the cast to text turns off math comparison rules.

David J.

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Jarosław Stokłosa
Дата:
Сообщение: Re: BUG #14046: Bad mathematical rules for 0 cast
Следующее
От: Tom Lane
Дата:
Сообщение: Re: BUG #14053: postgres crashes in plpgsql under load of concurrent transactions