From c6f153dcfebccf7a0d92290037793c656f1caef5 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 13 Mar 2019 18:13:38 -0400 Subject: [PATCH] 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 --- src/test/regress/expected/float8.out | 50 ++++++++++++++-------------- src/test/regress/sql/float8.sql | 16 ++++----- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/test/regress/expected/float8.out b/src/test/regress/expected/float8.out index 36b2acda73..7aed4aa97f 100644 --- a/src/test/regress/expected/float8.out +++ b/src/test/regress/expected/float8.out @@ -454,44 +454,44 @@ SELECT '' AS five, * FROM FLOAT8_TBL; | -1.2345678901234e-200 (5 rows) +RESET extra_float_digits; -- hyperbolic functions -SELECT sinh(float8 '0'); - sinh ------- - 0 +SELECT sinh(float8 '1'); + sinh +-------------------- + 1.1752011936438014 (1 row) -SELECT cosh(float8 '0'); - cosh ------- - 1 +SELECT cosh(float8 '1'); + cosh +-------------------- + 1.5430806348152437 (1 row) -SELECT tanh(float8 '0'); - tanh ------- - 0 +SELECT tanh(float8 '1'); + tanh +-------------------- + 0.7615941559557649 (1 row) -SELECT asinh(float8 '0'); - asinh -------- - 0 +SELECT asinh(float8 '1'); + asinh +------------------- + 0.881373587019543 (1 row) -SELECT acosh(float8 '1'); - acosh -------- - 0 +SELECT acosh(float8 '2'); + acosh +-------------------- + 1.3169578969248166 (1 row) -SELECT atanh(float8 '0'); - atanh -------- - 0 +SELECT atanh(float8 '0.5'); + atanh +-------------------- + 0.5493061443340548 (1 row) -RESET extra_float_digits; -- test for over- and underflow INSERT INTO FLOAT8_TBL(f1) VALUES ('10e400'); ERROR: "10e400" is out of range for type double precision diff --git a/src/test/regress/sql/float8.sql b/src/test/regress/sql/float8.sql index 4660cd265e..07fbb66c94 100644 --- a/src/test/regress/sql/float8.sql +++ b/src/test/regress/sql/float8.sql @@ -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'); -- 2.40.0