Rethink how to test the hyperbolic functions.

The initial commit tried to test them on trivial cases such as 0,
reasoning that we shouldn't hit any portability issues that way.
The buildfarm immediately proved that hope ill-founded, and anyway
it's not a great testing scheme because it doesn't prove that we're
even calling the right library function for each SQL function.

Instead, let's test them at inputs such as 1 (or something within
the valid range, as needed), so that each function should produce
a different output.

As committed, this is just about certain to show portability
failures, because it's very unlikely that every platform computes
these functions the same as mine down to the last bit.  However,
I want to put it through a buildfarm cycle this way, so that
we can see how big the variations are.  The plan is to add
"set extra_float_digits = -1", or whatever we need in order to
hide the variations; but first we need data.

Discussion: https://postgr.es/m/E1h3nUY-0000sM-Vf@gemulon.postgresql.org
This commit is contained in:
Tom Lane 2019-03-13 18:13:38 -04:00
parent c6c9474aaf
commit c6f153dcfe
2 changed files with 45 additions and 45 deletions

View File

@ -454,44 +454,44 @@ SELECT '' AS five, * FROM FLOAT8_TBL;
| -1.2345678901234e-200
(5 rows)
-- hyperbolic functions
SELECT sinh(float8 '0');
sinh
------
0
(1 row)
SELECT cosh(float8 '0');
cosh
------
1
(1 row)
SELECT tanh(float8 '0');
tanh
------
0
(1 row)
SELECT asinh(float8 '0');
asinh
-------
0
(1 row)
SELECT acosh(float8 '1');
acosh
-------
0
(1 row)
SELECT atanh(float8 '0');
atanh
-------
0
(1 row)
RESET extra_float_digits;
-- hyperbolic functions
SELECT sinh(float8 '1');
sinh
--------------------
1.1752011936438014
(1 row)
SELECT cosh(float8 '1');
cosh
--------------------
1.5430806348152437
(1 row)
SELECT tanh(float8 '1');
tanh
--------------------
0.7615941559557649
(1 row)
SELECT asinh(float8 '1');
asinh
-------------------
0.881373587019543
(1 row)
SELECT acosh(float8 '2');
acosh
--------------------
1.3169578969248166
(1 row)
SELECT atanh(float8 '0.5');
atanh
--------------------
0.5493061443340548
(1 row)
-- test for over- and underflow
INSERT INTO FLOAT8_TBL(f1) VALUES ('10e400');
ERROR: "10e400" is out of range for type double precision

View File

@ -154,16 +154,16 @@ SELECT '' AS bad, f.f1 / '0.0' from FLOAT8_TBL f;
SELECT '' AS five, * FROM FLOAT8_TBL;
-- hyperbolic functions
SELECT sinh(float8 '0');
SELECT cosh(float8 '0');
SELECT tanh(float8 '0');
SELECT asinh(float8 '0');
SELECT acosh(float8 '1');
SELECT atanh(float8 '0');
RESET extra_float_digits;
-- hyperbolic functions
SELECT sinh(float8 '1');
SELECT cosh(float8 '1');
SELECT tanh(float8 '1');
SELECT asinh(float8 '1');
SELECT acosh(float8 '2');
SELECT atanh(float8 '0.5');
-- test for over- and underflow
INSERT INTO FLOAT8_TBL(f1) VALUES ('10e400');