--
-- FLOAT8
--
-- test for underflow and overflow handling
SELECT '10e400'::float8;
psql:/home/runner/.ya/build/build_root/f6zk/0031e5/environment/arcadia/ydb/tests/functional/postgresql/cases/float8.sql:6: Status: PRECONDITION_FAILED
Issues: 
<main>: Error: Terminate was called, reason(59): ERROR:  "10e400" is out of range for type double precision



SELECT '-10e400'::float8;
psql:/home/runner/.ya/build/build_root/f6zk/0031e5/environment/arcadia/ydb/tests/functional/postgresql/cases/float8.sql:7: Status: PRECONDITION_FAILED
Issues: 
<main>: Error: Terminate was called, reason(60): ERROR:  "-10e400" is out of range for type double precision



SELECT '10e-400'::float8;
psql:/home/runner/.ya/build/build_root/f6zk/0031e5/environment/arcadia/ydb/tests/functional/postgresql/cases/float8.sql:8: Status: PRECONDITION_FAILED
Issues: 
<main>: Error: Terminate was called, reason(60): ERROR:  "10e-400" is out of range for type double precision



SELECT '-10e-400'::float8;
psql:/home/runner/.ya/build/build_root/f6zk/0031e5/environment/arcadia/ydb/tests/functional/postgresql/cases/float8.sql:9: Status: PRECONDITION_FAILED
Issues: 
<main>: Error: Terminate was called, reason(61): ERROR:  "-10e-400" is out of range for type double precision



-- bad special inputs
SELECT 'N A N'::float8;
psql:/home/runner/.ya/build/build_root/f6zk/0031e5/environment/arcadia/ydb/tests/functional/postgresql/cases/float8.sql:11: Status: PRECONDITION_FAILED
Issues: 
<main>: Error: Terminate was called, reason(64): ERROR:  invalid input syntax for type double precision: "N A N"



SELECT 'NaN x'::float8;
psql:/home/runner/.ya/build/build_root/f6zk/0031e5/environment/arcadia/ydb/tests/functional/postgresql/cases/float8.sql:12: Status: PRECONDITION_FAILED
Issues: 
<main>: Error: Terminate was called, reason(64): ERROR:  invalid input syntax for type double precision: "NaN x"



SELECT ' INFINITY    x'::float8;
psql:/home/runner/.ya/build/build_root/f6zk/0031e5/environment/arcadia/ydb/tests/functional/postgresql/cases/float8.sql:13: Status: PRECONDITION_FAILED
Issues: 
<main>: Error: Terminate was called, reason(73): ERROR:  invalid input syntax for type double precision: " INFINITY    x"



SELECT '42'::float8 / 'Infinity'::float8;
 column0 
---------
       0
(1 row)

-- square root
SELECT sqrt(float8 '64') AS eight;
 eight 
-------
     8
(1 row)

SELECT |/ float8 '64' AS eight;
 eight 
-------
     8
(1 row)

-- power
SELECT power(float8 '144', float8 '0.5');
 power 
-------
    12
(1 row)

SELECT power(float8 '1', float8 'NaN');
 power 
-------
     1
(1 row)

SELECT power(float8 'NaN', float8 '0');
 power 
-------
     1
(1 row)

SELECT power(float8 'inf', float8 '0');
 power 
-------
     1
(1 row)

SELECT power(float8 '-inf', float8 '0');
 power 
-------
     1
(1 row)

SELECT power(float8 '0', float8 'inf');
 power 
-------
     0
(1 row)

SELECT power(float8 '0', float8 '-inf');
psql:/home/runner/.ya/build/build_root/f6zk/0031e5/environment/arcadia/ydb/tests/functional/postgresql/cases/float8.sql:29: Status: PRECONDITION_FAILED
Issues: 
<main>: Error: Terminate was called, reason(53): ERROR:  zero raised to a negative power is undefined



SELECT power(float8 '1', float8 'inf');
 power 
-------
     1
(1 row)

SELECT power(float8 '1', float8 '-inf');
 power 
-------
     1
(1 row)

SELECT power(float8 '-1', float8 'inf');
 power 
-------
     1
(1 row)

SELECT power(float8 '-1', float8 '-inf');
 power 
-------
     1
(1 row)

SELECT power(float8 '0.1', float8 'inf');
 power 
-------
     0
(1 row)

SELECT power(float8 '-0.1', float8 'inf');
 power 
-------
     0
(1 row)

SELECT power(float8 '1.1', float8 '-inf');
 power 
-------
     0
(1 row)

SELECT power(float8 '-1.1', float8 '-inf');
 power 
-------
     0
(1 row)

SELECT power(float8 'inf', float8 '-2');
 power 
-------
     0
(1 row)

SELECT power(float8 'inf', float8 '-inf');
 power 
-------
     0
(1 row)

SELECT power(float8 '-inf', float8 '-3');
 power 
-------
    -0
(1 row)

SELECT power(float8 '-inf', float8 '3.5');
psql:/home/runner/.ya/build/build_root/f6zk/0031e5/environment/arcadia/ydb/tests/functional/postgresql/cases/float8.sql:42: Status: PRECONDITION_FAILED
Issues: 
<main>: Error: Terminate was called, reason(80): ERROR:  a negative number raised to a non-integer power yields a complex result



SELECT power(float8 '-inf', float8 '-inf');
 power 
-------
     0
(1 row)

SELECT tanh(float8 'infinity');
 tanh 
------
    1
(1 row)

SELECT tanh(float8 '-infinity');
 tanh 
------
   -1
(1 row)

-- acosh(Inf) should be Inf, but some mingw versions produce NaN, so skip test
-- SELECT acosh(float8 'infinity');
SELECT acosh(float8 '-infinity');
psql:/home/runner/.ya/build/build_root/f6zk/0031e5/environment/arcadia/ydb/tests/functional/postgresql/cases/float8.sql:48: Status: PRECONDITION_FAILED
Issues: 
<main>: Error: Terminate was called, reason(30): ERROR:  input is out of range



SELECT atanh(float8 'infinity');
psql:/home/runner/.ya/build/build_root/f6zk/0031e5/environment/arcadia/ydb/tests/functional/postgresql/cases/float8.sql:49: Status: PRECONDITION_FAILED
Issues: 
<main>: Error: Terminate was called, reason(30): ERROR:  input is out of range



SELECT atanh(float8 '-infinity');
psql:/home/runner/.ya/build/build_root/f6zk/0031e5/environment/arcadia/ydb/tests/functional/postgresql/cases/float8.sql:50: Status: PRECONDITION_FAILED
Issues: 
<main>: Error: Terminate was called, reason(30): ERROR:  input is out of range



-- test edge-case coercions to integer
SELECT '32767.4'::float8::int2;
 column0 
---------
   32767
(1 row)

SELECT '32767.6'::float8::int2;
psql:/home/runner/.ya/build/build_root/f6zk/0031e5/environment/arcadia/ydb/tests/functional/postgresql/cases/float8.sql:53: Status: PRECONDITION_FAILED
Issues: 
<main>: Error: Terminate was called, reason(30): ERROR:  smallint out of range



SELECT '-32768.4'::float8::int2;
 column0 
---------
  -32768
(1 row)

SELECT '-32768.6'::float8::int2;
psql:/home/runner/.ya/build/build_root/f6zk/0031e5/environment/arcadia/ydb/tests/functional/postgresql/cases/float8.sql:55: Status: PRECONDITION_FAILED
Issues: 
<main>: Error: Terminate was called, reason(30): ERROR:  smallint out of range



SELECT '2147483647.4'::float8::int4;
  column0   
------------
 2147483647
(1 row)

SELECT '2147483647.6'::float8::int4;
psql:/home/runner/.ya/build/build_root/f6zk/0031e5/environment/arcadia/ydb/tests/functional/postgresql/cases/float8.sql:57: Status: PRECONDITION_FAILED
Issues: 
<main>: Error: Terminate was called, reason(29): ERROR:  integer out of range



SELECT '-2147483648.4'::float8::int4;
   column0   
-------------
 -2147483648
(1 row)

SELECT '-2147483648.6'::float8::int4;
psql:/home/runner/.ya/build/build_root/f6zk/0031e5/environment/arcadia/ydb/tests/functional/postgresql/cases/float8.sql:59: Status: PRECONDITION_FAILED
Issues: 
<main>: Error: Terminate was called, reason(29): ERROR:  integer out of range



SELECT '9223372036854773760'::float8::int8;
       column0       
---------------------
 9223372036854773760
(1 row)

SELECT '9223372036854775807'::float8::int8;
psql:/home/runner/.ya/build/build_root/f6zk/0031e5/environment/arcadia/ydb/tests/functional/postgresql/cases/float8.sql:61: Status: PRECONDITION_FAILED
Issues: 
<main>: Error: Terminate was called, reason(28): ERROR:  bigint out of range



SELECT '-9223372036854775808.5'::float8::int8;
       column0        
----------------------
 -9223372036854775808
(1 row)

SELECT '-9223372036854780000'::float8::int8;
psql:/home/runner/.ya/build/build_root/f6zk/0031e5/environment/arcadia/ydb/tests/functional/postgresql/cases/float8.sql:63: Status: PRECONDITION_FAILED
Issues: 
<main>: Error: Terminate was called, reason(28): ERROR:  bigint out of range



