pgsql: Put back ERANGE test in dpow().

Started by Tom Laneover 19 years ago5 messagescomitterspatches
Jump to latest
#1Tom Lane
tgl@sss.pgh.pa.us
comitterspatches

Log Message:
-----------
Put back ERANGE test in dpow(). There are platforms that need this,
like my HPPA ...

Modified Files:
--------------
pgsql/src/backend/utils/adt:
float.c (r1.142 -> r1.143)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/adt/float.c.diff?r1=1.142&r2=1.143)

#2Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#1)
comitterspatches
Re: [COMMITTERS] pgsql: Put back ERANGE test in dpow().

Tom Lane wrote:

Log Message:
-----------
Put back ERANGE test in dpow(). There are platforms that need this,
like my HPPA ...

It ERANGE's only on Inf, not underflow? I would prefer:

else if (errno == ERANGE && !isinf(result))

because the sign computation isn't 100%, think pow(-1e300, 2) == Inf,
not -Inf. But of course, that is going throw an error anyway, so either
we care about the sign of the Inf and try to get it right using isinf(),
or we just ignore it and use +Inf always.

--
Bruce Momjian bruce@momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#2)
comitterspatches
Re: [COMMITTERS] pgsql: Put back ERANGE test in dpow().

Bruce Momjian <bruce@momjian.us> writes:

It ERANGE's only on Inf, not underflow? I would prefer:
else if (errno == ERANGE && !isinf(result))

No objection to that, just don't take out the ERANGE test altogether
again ;-)

regards, tom lane

#4Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#3)
comitterspatches
Re: [COMMITTERS] pgsql: Put back ERANGE test in

Tom Lane wrote:

Bruce Momjian <bruce@momjian.us> writes:

It ERANGE's only on Inf, not underflow? I would prefer:
else if (errno == ERANGE && !isinf(result))

No objection to that, just don't take out the ERANGE test altogether
again ;-)

Actually, when you return ERANGE, what is 'result'? Nan? Inf? finite?

--
Bruce Momjian bruce@momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#4)
comitterspatches
Re: [COMMITTERS] pgsql: Put back ERANGE test in dpow().

Bruce Momjian <bruce@momjian.us> writes:

Actually, when you return ERANGE, what is 'result'? Nan? Inf? finite?

I believe it's HUGE_VAL (the largest finite value) ... which is
something I don't want to explicitly test for, any more than I liked
the explicit use of min/max values before. Your isinf test is OK
because the point is that we want to replace any non-Inf result with Inf
if the result overflowed.

regards, tom lane