pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jarosław Stokłosa <jaroslaw.stoklosa@nomino.pl>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: John McKown <john.archie.mckown@gmail.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #14046: Bad mathematical rules for 0 cast
Date: Thu, 31 Mar 2016 09:49:00 +0200
Message-ID: <56FCD66C.1010302@nomino.pl> (raw)
In-Reply-To: <18628.1459355531@sss.pgh.pa.us>
References: <20160325085614.2915.72425@wrigleys.postgresql.org>
	<CAAJSdjhfjrtzPjtNbf=qGeD1o+cwxfYLo_9nB2_AsVODQB7Gog@mail.gmail.com>
	<56FB7853.5090803@nomino.pl>
	<18628.1459355531@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

W dniu 30/03/2016 o 18:32, Tom Lane pisze:
> =?UTF-8?Q?Jaros=c5=82aw_Stok=c5=82osa?= <jaroslaw.stoklosa@nomino.pl> writes:
>>> ​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. ​
>> I'm disagee with you. PostgreSQL don't distinguish +0 from -0 because
>> cast('+0' as FLOAT) = 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.
> Sorry, but that argument isn't terribly convincing.  The point is exactly
> whether casting to another type must preserve equality, and you're just
> asserting that it should be so without providing any compelling reason.
>
> There are plenty of other counterexamples to that, though.  One that
> comes to mind is that 42::numeric(6,3) will compare equal to
> 42::numeric(6,0), but if you cast them to text you will get '42.000'
> and '42', which are not equal according to text's rules.  Another is
> that 'FOO' and 'foo' compare equal according to citext, but if you
> cast them to text they aren't equal anymore.
>
> Basically, different types are allowed to have different equality
> behaviors.  That's too useful to give up in the (vain) pursuit of
> somebody's notion of mathematical purity.

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.
Regards,
Jarek Stokłosa


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



view thread (10+ messages)  latest in thread

Message-ID: <56FCD66C.1010302@nomino.pl>
Permalink:  ../56FCD66C.1010302@nomino.pl/
Also on:    postgresql.org/message-id/56FCD66C.1010302@nomino.pl

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: jaroslaw.stoklosa@nomino.pl, tgl@sss.pgh.pa.us, john.archie.mckown@gmail.com
  Subject: Re: BUG #14046: Bad mathematical rules for 0 cast
  In-Reply-To: <56FCD66C.1010302@nomino.pl>
  References: <20160325085614.2915.72425@wrigleys.postgresql.org> <CAAJSdjhfjrtzPjtNbf=qGeD1o+cwxfYLo_9nB2_AsVODQB7Gog@mail.gmail.com> <56FB7853.5090803@nomino.pl> <18628.1459355531@sss.pgh.pa.us> <56FCD66C.1010302@nomino.pl>

* 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