Re: exp() versus the POSIX standard

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: exp() versus the POSIX standard
Date: 2020-06-11 23:56:49
Message-ID: 583847.1591919809@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I wrote:
> The POSIX standard says this about the exp(3) function:
> If x is -Inf, +0 shall be returned.
> At least on my Linux box, our version does no such thing:
> regression=# select exp('-inf'::float8);
> ERROR: value out of range: underflow

Now that I look, power() has similar issues:

regression=# select power('1.1'::float8, '-inf');
ERROR: value out of range: underflow
regression=# select power('0.1'::float8, 'inf');
ERROR: value out of range: underflow
regression=# select power('-inf'::float8, '-3');
ERROR: value out of range: underflow
regression=# select power('-inf'::float8, '-4');
ERROR: value out of range: underflow

contradicting POSIX which says

For |x| > 1, if y is -Inf, +0 shall be returned.

For |x| < 1, if y is +Inf, +0 shall be returned.

For y an odd integer < 0, if x is -Inf, -0 shall be returned.

For y < 0 and not an odd integer, if x is -Inf, +0 shall be returned.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Darafei Komяpa Praliaskouski 2020-06-12 00:36:26 Re: exp() versus the POSIX standard
Previous Message Tom Lane 2020-06-11 23:22:32 exp() versus the POSIX standard