Commit 58193c5f authored by Tom Lane's avatar Tom Lane

Paranoia about unordered comparisons in IEEE float math. If we are

given values that compare as unordered, make sure we reply that they
are equal, which is better than giving an arbitrary answer --- at least
it doesn't depend on which one is passed as which arg.
parent fc7c16fd
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.71 2001/05/03 19:00:36 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.72 2001/06/02 17:12:12 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -566,10 +566,10 @@ float4_cmp_internal(float4 a, float4 b) ...@@ -566,10 +566,10 @@ float4_cmp_internal(float4 a, float4 b)
{ {
if (a > b) if (a > b)
return 1; return 1;
else if (a == b) else if (a < b)
return 0;
else
return -1; return -1;
else
return 0;
} }
} }
...@@ -662,10 +662,10 @@ float8_cmp_internal(float8 a, float8 b) ...@@ -662,10 +662,10 @@ float8_cmp_internal(float8 a, float8 b)
{ {
if (a > b) if (a > b)
return 1; return 1;
else if (a == b) else if (a < b)
return 0;
else
return -1; return -1;
else
return 0;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment