Regression failure for floats

Started by Bruce Momjianabout 22 years ago5 messageshackers
Jump to latest
#1Bruce Momjian
bruce@momjian.us

I am seeing the following regression failure for current CVS. On my OS,
BSD/OS 4.3, it seems once you hit Infinity, you can't negate it.
/usr/include/math.h has:

/* Generate an overflow to create +Inf; the multiply shuts up gcc 1 */
#define HUGE_VAL (1e250*1e250) /* IEEE: positive infinity */

and our float4in code has:

else if (strcasecmp(num, "-Infinity") == 0)
val = -HUGE_VAL;

Seems that doesn't work for me.

---------------------------------------------------------------------------

*** ./expected/float4.out	Sat Mar 13 23:07:10 2004
--- ./results/float4.out	Sat Mar 13 23:10:30 2004
***************
*** 58,65 ****

SELECT ' -INFINiTY '::float4;
float4
! -----------
! -Infinity
(1 row)

  -- bad special inputs
--- 58,65 ----

SELECT ' -INFINiTY '::float4;
float4
! ----------
! Infinity
(1 row)

-- bad special inputs

======================================================================

*** ./expected/float8.out	Sat Mar 13 23:07:10 2004
--- ./results/float8.out	Sat Mar 13 23:10:30 2004
***************
*** 58,65 ****

SELECT ' -INFINiTY '::float8;
float8
! -----------
! -Infinity
(1 row)

  -- bad special inputs
--- 58,65 ----

SELECT ' -INFINiTY '::float8;
float8
! ----------
! Infinity
(1 row)

-- bad special inputs

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#2Neil Conway
neilc@samurai.com
In reply to: Bruce Momjian (#1)
Re: Regression failure for floats

Bruce Momjian <pgman@candle.pha.pa.us> writes:

I am seeing the following regression failure for current CVS. On my
OS, BSD/OS 4.3, it seems once you hit Infinity, you can't negate it.

Actually, I suspect the problem is that isinf() on your platform
returns 1 for any infinity (rather than -1 for negative infinity and 1
for positive infinity). Some existing code in float4out() and
float8out() assumed that a positive return from isinf() indicated a
positive infinity, which is not per C99.

Anyway, Tom and I worked through this issue, and a couple other
portability problems with the recent float changes, via private
email. The current patch is attached -- Tom hasn't yet gotten back to
me on whether this fixes the problem for him on HPUX, but it fixes my
OS X box.

-Neil

Attachments:

float_input_strtod_portability-4.patchtext/x-patchDownload+190-137
#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#1)
Re: Regression failure for floats

Bruce Momjian <pgman@candle.pha.pa.us> writes:

I am seeing the following regression failure for current CVS. On my OS,
BSD/OS 4.3, it seems once you hit Infinity, you can't negate it.
/usr/include/math.h has:
/* Generate an overflow to create +Inf; the multiply shuts up gcc 1 */
#define HUGE_VAL (1e250*1e250) /* IEEE: positive infinity */
and our float4in code has:
else if (strcasecmp(num, "-Infinity") == 0)
val = -HUGE_VAL;
Seems that doesn't work for me.

No, the bug is that Neil assumed isinf() would tell him the sign of an
infinity. I believe he's about to commit a patch for this and some
other bogosities.

regards, tom lane

#4Neil Conway
neilc@samurai.com
In reply to: Neil Conway (#2)
Re: Regression failure for floats

Neil Conway <neilc@samurai.com> writes:

The current patch is attached -- Tom hasn't yet gotten back to me on
whether this fixes the problem for him on HPUX, but it fixes my OS X
box.

Patch applied to CVS.

-Neil

#5Claudio Natoli
claudio.natoli@memetrics.com
In reply to: Neil Conway (#4)
Re: Regression failure for floats

email. The current patch is attached -- Tom hasn't yet gotten back to
me on whether this fixes the problem for him on HPUX, but it fixes my
OS X box.

Fixes issues under win32. Thanks.

Claudio

--- 
Certain disclaimers and policies apply to all email sent from Memetrics.
For the full text of these disclaimers and policies see 
<a
href="http://www.memetrics.com/emailpolicy.html">http://www.memetrics.com/em
ailpolicy.html</a>