Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1allRX-0000ab-EW for pgsql-bugs@arkaria.postgresql.org; Thu, 31 Mar 2016 22:51:59 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1allRX-0000WU-1G for pgsql-bugs@arkaria.postgresql.org; Thu, 31 Mar 2016 22:51:59 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1alXMD-0004YX-0M for pgsql-bugs@postgresql.org; Thu, 31 Mar 2016 07:49:33 +0000 Received: from mailgw2.gradier.pl ([91.223.72.17]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1alXM9-0005Ge-Mb for pgsql-bugs@postgresql.org; Thu, 31 Mar 2016 07:49:31 +0000 Received: from localhost (localhost [127.0.0.1]) by mailgw2.gradier.pl (Postfix) with ESMTP id 94A455FF02; Thu, 31 Mar 2016 09:49:10 +0200 (CEST) X-Virus-Scanned: amavisd-new at gradier.net.pl Received: from mailgw2.gradier.pl ([127.0.0.1]) by localhost (mailgw2.gradier.pl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id KiwJK1dNoXYt; Thu, 31 Mar 2016 09:49:10 +0200 (CEST) Subject: Re: BUG #14046: Bad mathematical rules for 0 cast To: Tom Lane References: <20160325085614.2915.72425@wrigleys.postgresql.org> <56FB7853.5090803@nomino.pl> <18628.1459355531@sss.pgh.pa.us> Cc: John McKown , pgsql-bugs@postgresql.org From: =?UTF-8?Q?Jaros=c5=82aw_Stok=c5=82osa?= Message-ID: <56FCD66C.1010302@nomino.pl> Date: Thu, 31 Mar 2016 09:49:00 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <18628.1459355531@sss.pgh.pa.us> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org W dniu 30/03/2016 o 18:32, Tom Lane pisze: > =?UTF-8?Q?Jaros=c5=82aw_Stok=c5=82osa?= 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