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.
How would you propose to implement this "or"?
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.
Agreed. It is the cast to text turns off math comparison rules.
David J.
Hi David, Tom, John,
Solution for me: SELECT cast('+0' as FLOAT) = cast('-0' as FLOAT), cast('+0' as FLOAT)::NUMERIC::FLOAT::TEXT= cast('-0' as FLOAT)::NUMERIC::FLOAT::TEXT There are 2 times TRUE.
Thank you for your opinion and objective discussion.