1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

Change floating-point output format for improved performance.

Previously, floating-point output was done by rounding to a specific
decimal precision; by default, to 6 or 15 decimal digits (losing
information) or as requested using extra_float_digits. Drivers that
wanted exact float values, and applications like pg_dump that must
preserve values exactly, set extra_float_digits=3 (or sometimes 2 for
historical reasons, though this isn't enough for float4).

Unfortunately, decimal rounded output is slow enough to become a
noticable bottleneck when dealing with large result sets or COPY of
large tables when many floating-point values are involved.

Floating-point output can be done much faster when the output is not
rounded to a specific decimal length, but rather is chosen as the
shortest decimal representation that is closer to the original float
value than to any other value representable in the same precision. The
recently published Ryu algorithm by Ulf Adams is both relatively
simple and remarkably fast.

Accordingly, change float4out/float8out to output shortest decimal
representations if extra_float_digits is greater than 0, and make that
the new default. Applications that need rounded output can set
extra_float_digits back to 0 or below, and take the resulting
performance hit.

We make one concession to portability for systems with buggy
floating-point input: we do not output decimal values that fall
exactly halfway between adjacent representable binary values (which
would rely on the reader doing round-to-nearest-even correctly). This
is known to be a problem at least for VS2013 on Windows.

Our version of the Ryu code originates from
https://github.com/ulfjack/ryu/ at commit c9c3fb1979, but with the
following (significant) modifications:

 - Output format is changed to use fixed-point notation for small
   exponents, as printf would, and also to use lowercase 'e', a
   minimum of 2 exponent digits, and a mandatory sign on the exponent,
   to keep the formatting as close as possible to previous output.

 - The output of exact midpoint values is disabled as noted above.

 - The integer fast-path code is changed somewhat (since we have
   fixed-point output and the upstream did not).

 - Our project style has been largely applied to the code with the
   exception of C99 declaration-after-statement, which has been
   retained as an exception to our present policy.

 - Most of upstream's debugging and conditionals are removed, and we
   use our own configure tests to determine things like uint128
   availability.

Changing the float output format obviously affects a number of
regression tests. This patch uses an explicit setting of
extra_float_digits=0 for test output that is not expected to be
exactly reproducible (e.g. due to numerical instability or differing
algorithms for transcendental functions).

Conversions from floats to numeric are unchanged by this patch. These
may appear in index expressions and it is not yet clear whether any
change should be made, so that can be left for another day.

This patch assumes that the only supported floating point format is
now IEEE format, and the documentation is updated to reflect that.

Code by me, adapting the work of Ulf Adams and other contributors.

References:
https://dl.acm.org/citation.cfm?id=3192369

Reviewed-by: Tom Lane, Andres Freund, Donald Dong
Discussion: https://postgr.es/m/87r2el1bx6.fsf@news-spur.riddles.org.uk
This commit is contained in:
Andrew Gierth
2019-02-13 15:20:33 +00:00
parent f397e08599
commit 02ddd49932
50 changed files with 5466 additions and 368 deletions

View File

@ -1,6 +1,8 @@
--
-- AGGREGATES
--
-- avoid bit-exact output here because operations may not be bit-exact.
SET extra_float_digits = 0;
SELECT avg(four) AS avg_1 FROM onek;
avg_1
--------------------

View File

@ -1,6 +1,8 @@
--
-- CIRCLE
--
-- avoid bit-exact output here because operations may not be bit-exact.
SET extra_float_digits = 0;
CREATE TABLE CIRCLE_TBL (f1 circle);
INSERT INTO CIRCLE_TBL VALUES ('<(5,1),3>');
INSERT INTO CIRCLE_TBL VALUES ('<(1,2),100>');

View File

@ -142,22 +142,22 @@ SELECT 'nan'::numeric::float4;
(1 row)
SELECT '' AS five, * FROM FLOAT4_TBL;
five | f1
------+-------------
| 0
| 1004.3
| -34.84
| 1.23457e+20
| 1.23457e-20
five | f1
------+---------------
| 0
| 1004.3
| -34.84
| 1.2345679e+20
| 1.2345679e-20
(5 rows)
SELECT '' AS four, f.* FROM FLOAT4_TBL f WHERE f.f1 <> '1004.3';
four | f1
------+-------------
| 0
| -34.84
| 1.23457e+20
| 1.23457e-20
four | f1
------+---------------
| 0
| -34.84
| 1.2345679e+20
| 1.2345679e-20
(4 rows)
SELECT '' AS one, f.* FROM FLOAT4_TBL f WHERE f.f1 = '1004.3';
@ -167,110 +167,110 @@ SELECT '' AS one, f.* FROM FLOAT4_TBL f WHERE f.f1 = '1004.3';
(1 row)
SELECT '' AS three, f.* FROM FLOAT4_TBL f WHERE '1004.3' > f.f1;
three | f1
-------+-------------
| 0
| -34.84
| 1.23457e-20
three | f1
-------+---------------
| 0
| -34.84
| 1.2345679e-20
(3 rows)
SELECT '' AS three, f.* FROM FLOAT4_TBL f WHERE f.f1 < '1004.3';
three | f1
-------+-------------
| 0
| -34.84
| 1.23457e-20
three | f1
-------+---------------
| 0
| -34.84
| 1.2345679e-20
(3 rows)
SELECT '' AS four, f.* FROM FLOAT4_TBL f WHERE '1004.3' >= f.f1;
four | f1
------+-------------
| 0
| 1004.3
| -34.84
| 1.23457e-20
four | f1
------+---------------
| 0
| 1004.3
| -34.84
| 1.2345679e-20
(4 rows)
SELECT '' AS four, f.* FROM FLOAT4_TBL f WHERE f.f1 <= '1004.3';
four | f1
------+-------------
| 0
| 1004.3
| -34.84
| 1.23457e-20
four | f1
------+---------------
| 0
| 1004.3
| -34.84
| 1.2345679e-20
(4 rows)
SELECT '' AS three, f.f1, f.f1 * '-10' AS x FROM FLOAT4_TBL f
WHERE f.f1 > '0.0';
three | f1 | x
-------+-------------+--------------
| 1004.3 | -10043
| 1.23457e+20 | -1.23457e+21
| 1.23457e-20 | -1.23457e-19
three | f1 | x
-------+---------------+----------------
| 1004.3 | -10043
| 1.2345679e+20 | -1.2345678e+21
| 1.2345679e-20 | -1.2345678e-19
(3 rows)
SELECT '' AS three, f.f1, f.f1 + '-10' AS x FROM FLOAT4_TBL f
WHERE f.f1 > '0.0';
three | f1 | x
-------+-------------+-------------
| 1004.3 | 994.3
| 1.23457e+20 | 1.23457e+20
| 1.23457e-20 | -10
three | f1 | x
-------+---------------+---------------
| 1004.3 | 994.3
| 1.2345679e+20 | 1.2345679e+20
| 1.2345679e-20 | -10
(3 rows)
SELECT '' AS three, f.f1, f.f1 / '-10' AS x FROM FLOAT4_TBL f
WHERE f.f1 > '0.0';
three | f1 | x
-------+-------------+--------------
| 1004.3 | -100.43
| 1.23457e+20 | -1.23457e+19
| 1.23457e-20 | -1.23457e-21
three | f1 | x
-------+---------------+----------------
| 1004.3 | -100.43
| 1.2345679e+20 | -1.2345679e+19
| 1.2345679e-20 | -1.2345679e-21
(3 rows)
SELECT '' AS three, f.f1, f.f1 - '-10' AS x FROM FLOAT4_TBL f
WHERE f.f1 > '0.0';
three | f1 | x
-------+-------------+-------------
| 1004.3 | 1014.3
| 1.23457e+20 | 1.23457e+20
| 1.23457e-20 | 10
three | f1 | x
-------+---------------+---------------
| 1004.3 | 1014.3
| 1.2345679e+20 | 1.2345679e+20
| 1.2345679e-20 | 10
(3 rows)
-- test divide by zero
SELECT '' AS bad, f.f1 / '0.0' from FLOAT4_TBL f;
ERROR: division by zero
SELECT '' AS five, * FROM FLOAT4_TBL;
five | f1
------+-------------
| 0
| 1004.3
| -34.84
| 1.23457e+20
| 1.23457e-20
five | f1
------+---------------
| 0
| 1004.3
| -34.84
| 1.2345679e+20
| 1.2345679e-20
(5 rows)
-- test the unary float4abs operator
SELECT '' AS five, f.f1, @f.f1 AS abs_f1 FROM FLOAT4_TBL f;
five | f1 | abs_f1
------+-------------+-------------
| 0 | 0
| 1004.3 | 1004.3
| -34.84 | 34.84
| 1.23457e+20 | 1.23457e+20
| 1.23457e-20 | 1.23457e-20
five | f1 | abs_f1
------+---------------+---------------
| 0 | 0
| 1004.3 | 1004.3
| -34.84 | 34.84
| 1.2345679e+20 | 1.2345679e+20
| 1.2345679e-20 | 1.2345679e-20
(5 rows)
UPDATE FLOAT4_TBL
SET f1 = FLOAT4_TBL.f1 * '-1'
WHERE FLOAT4_TBL.f1 > '0.0';
SELECT '' AS five, * FROM FLOAT4_TBL;
five | f1
------+--------------
| 0
| -34.84
| -1004.3
| -1.23457e+20
| -1.23457e-20
five | f1
------+----------------
| 0
| -34.84
| -1004.3
| -1.2345679e+20
| -1.2345679e-20
(5 rows)
-- test edge-case coercions to integer
@ -434,3 +434,507 @@ SELECT float4send('1.1754944e-38'::float4);
\x00800000
(1 row)
-- test output (and round-trip safety) of various values.
-- To ensure we're testing what we think we're testing, start with
-- float values specified by bit patterns (as a useful side effect,
-- this means we'll fail on non-IEEE platforms).
create type xfloat4;
create function xfloat4in(cstring) returns xfloat4 immutable strict
language internal as 'int4in';
NOTICE: return type xfloat4 is only a shell
create function xfloat4out(xfloat4) returns cstring immutable strict
language internal as 'int4out';
NOTICE: argument type xfloat4 is only a shell
create type xfloat4 (input = xfloat4in, output = xfloat4out, like = float4);
create cast (xfloat4 as float4) without function;
create cast (float4 as xfloat4) without function;
create cast (xfloat4 as integer) without function;
create cast (integer as xfloat4) without function;
-- float4: seeeeeee emmmmmmm mmmmmmmm mmmmmmmm
-- we don't care to assume the platform's strtod() handles subnormals
-- correctly; those are "use at your own risk". However we do test
-- subnormal outputs, since those are under our control.
with testdata(bits) as (values
-- small subnormals
(x'00000001'),
(x'00000002'), (x'00000003'),
(x'00000010'), (x'00000011'), (x'00000100'), (x'00000101'),
(x'00004000'), (x'00004001'), (x'00080000'), (x'00080001'),
-- stress values
(x'0053c4f4'), -- 7693e-42
(x'006c85c4'), -- 996622e-44
(x'0041ca76'), -- 60419369e-46
(x'004b7678'), -- 6930161142e-48
-- taken from upstream testsuite
(x'00000007'),
(x'00424fe2'),
-- borderline between subnormal and normal
(x'007ffff0'), (x'007ffff1'), (x'007ffffe'), (x'007fffff'))
select float4send(flt) as ibits,
flt
from (select bits::integer::xfloat4::float4 as flt
from testdata
offset 0) s;
ibits | flt
------------+---------------
\x00000001 | 1e-45
\x00000002 | 3e-45
\x00000003 | 4e-45
\x00000010 | 2.2e-44
\x00000011 | 2.4e-44
\x00000100 | 3.59e-43
\x00000101 | 3.6e-43
\x00004000 | 2.2959e-41
\x00004001 | 2.296e-41
\x00080000 | 7.34684e-40
\x00080001 | 7.34685e-40
\x0053c4f4 | 7.693e-39
\x006c85c4 | 9.96622e-39
\x0041ca76 | 6.041937e-39
\x004b7678 | 6.930161e-39
\x00000007 | 1e-44
\x00424fe2 | 6.0898e-39
\x007ffff0 | 1.1754921e-38
\x007ffff1 | 1.1754922e-38
\x007ffffe | 1.1754941e-38
\x007fffff | 1.1754942e-38
(21 rows)
with testdata(bits) as (values
(x'00000000'),
-- smallest normal values
(x'00800000'), (x'00800001'), (x'00800004'), (x'00800005'),
(x'00800006'),
-- small normal values chosen for short vs. long output
(x'008002f1'), (x'008002f2'), (x'008002f3'),
(x'00800e17'), (x'00800e18'), (x'00800e19'),
-- assorted values (random mantissae)
(x'01000001'), (x'01102843'), (x'01a52c98'),
(x'0219c229'), (x'02e4464d'), (x'037343c1'), (x'03a91b36'),
(x'047ada65'), (x'0496fe87'), (x'0550844f'), (x'05999da3'),
(x'060ea5e2'), (x'06e63c45'), (x'07f1e548'), (x'0fc5282b'),
(x'1f850283'), (x'2874a9d6'),
-- values around 5e-08
(x'3356bf94'), (x'3356bf95'), (x'3356bf96'),
-- around 1e-07
(x'33d6bf94'), (x'33d6bf95'), (x'33d6bf96'),
-- around 3e-07 .. 1e-04
(x'34a10faf'), (x'34a10fb0'), (x'34a10fb1'),
(x'350637bc'), (x'350637bd'), (x'350637be'),
(x'35719786'), (x'35719787'), (x'35719788'),
(x'358637bc'), (x'358637bd'), (x'358637be'),
(x'36a7c5ab'), (x'36a7c5ac'), (x'36a7c5ad'),
(x'3727c5ab'), (x'3727c5ac'), (x'3727c5ad'),
-- format crossover at 1e-04
(x'38d1b714'), (x'38d1b715'), (x'38d1b716'),
(x'38d1b717'), (x'38d1b718'), (x'38d1b719'),
(x'38d1b71a'), (x'38d1b71b'), (x'38d1b71c'),
(x'38d1b71d'),
--
(x'38dffffe'), (x'38dfffff'), (x'38e00000'),
(x'38efffff'), (x'38f00000'), (x'38f00001'),
(x'3a83126e'), (x'3a83126f'), (x'3a831270'),
(x'3c23d709'), (x'3c23d70a'), (x'3c23d70b'),
(x'3dcccccc'), (x'3dcccccd'), (x'3dccccce'),
-- chosen to need 9 digits for 3dcccd70
(x'3dcccd6f'), (x'3dcccd70'), (x'3dcccd71'),
--
(x'3effffff'), (x'3f000000'), (x'3f000001'),
(x'3f333332'), (x'3f333333'), (x'3f333334'),
-- approach 1.0 with increasing numbers of 9s
(x'3f666665'), (x'3f666666'), (x'3f666667'),
(x'3f7d70a3'), (x'3f7d70a4'), (x'3f7d70a5'),
(x'3f7fbe76'), (x'3f7fbe77'), (x'3f7fbe78'),
(x'3f7ff971'), (x'3f7ff972'), (x'3f7ff973'),
(x'3f7fff57'), (x'3f7fff58'), (x'3f7fff59'),
(x'3f7fffee'), (x'3f7fffef'),
-- values very close to 1
(x'3f7ffff0'), (x'3f7ffff1'), (x'3f7ffff2'),
(x'3f7ffff3'), (x'3f7ffff4'), (x'3f7ffff5'),
(x'3f7ffff6'), (x'3f7ffff7'), (x'3f7ffff8'),
(x'3f7ffff9'), (x'3f7ffffa'), (x'3f7ffffb'),
(x'3f7ffffc'), (x'3f7ffffd'), (x'3f7ffffe'),
(x'3f7fffff'),
(x'3f800000'),
(x'3f800001'), (x'3f800002'), (x'3f800003'),
(x'3f800004'), (x'3f800005'), (x'3f800006'),
(x'3f800007'), (x'3f800008'), (x'3f800009'),
-- values 1 to 1.1
(x'3f80000f'), (x'3f800010'), (x'3f800011'),
(x'3f800012'), (x'3f800013'), (x'3f800014'),
(x'3f800017'), (x'3f800018'), (x'3f800019'),
(x'3f80001a'), (x'3f80001b'), (x'3f80001c'),
(x'3f800029'), (x'3f80002a'), (x'3f80002b'),
(x'3f800053'), (x'3f800054'), (x'3f800055'),
(x'3f800346'), (x'3f800347'), (x'3f800348'),
(x'3f8020c4'), (x'3f8020c5'), (x'3f8020c6'),
(x'3f8147ad'), (x'3f8147ae'), (x'3f8147af'),
(x'3f8ccccc'), (x'3f8ccccd'), (x'3f8cccce'),
--
(x'3fc90fdb'), -- pi/2
(x'402df854'), -- e
(x'40490fdb'), -- pi
--
(x'409fffff'), (x'40a00000'), (x'40a00001'),
(x'40afffff'), (x'40b00000'), (x'40b00001'),
(x'411fffff'), (x'41200000'), (x'41200001'),
(x'42c7ffff'), (x'42c80000'), (x'42c80001'),
(x'4479ffff'), (x'447a0000'), (x'447a0001'),
(x'461c3fff'), (x'461c4000'), (x'461c4001'),
(x'47c34fff'), (x'47c35000'), (x'47c35001'),
(x'497423ff'), (x'49742400'), (x'49742401'),
(x'4b18967f'), (x'4b189680'), (x'4b189681'),
(x'4cbebc1f'), (x'4cbebc20'), (x'4cbebc21'),
(x'4e6e6b27'), (x'4e6e6b28'), (x'4e6e6b29'),
(x'501502f8'), (x'501502f9'), (x'501502fa'),
(x'51ba43b6'), (x'51ba43b7'), (x'51ba43b8'),
-- stress values
(x'1f6c1e4a'), -- 5e-20
(x'59be6cea'), -- 67e14
(x'5d5ab6c4'), -- 985e15
(x'2cc4a9bd'), -- 55895e-16
(x'15ae43fd'), -- 7038531e-32
(x'2cf757ca'), -- 702990899e-20
(x'665ba998'), -- 25933168707e13
(x'743c3324'), -- 596428896559e20
-- exercise fixed-point memmoves
(x'47f1205a'),
(x'4640e6ae'),
(x'449a5225'),
(x'42f6e9d5'),
(x'414587dd'),
(x'3f9e064b'),
-- these cases come from the upstream's testsuite
-- BoundaryRoundEven
(x'4c000004'),
(x'50061c46'),
(x'510006a8'),
-- ExactValueRoundEven
(x'48951f84'),
(x'45fd1840'),
-- LotsOfTrailingZeros
(x'39800000'),
(x'3b200000'),
(x'3b900000'),
(x'3bd00000'),
-- Regression
(x'63800000'),
(x'4b000000'),
(x'4b800000'),
(x'4c000001'),
(x'4c800b0d'),
(x'00d24584'),
(x'800000b0'),
(x'00d90b88'),
(x'45803f34'),
(x'4f9f24f7'),
(x'3a8722c3'),
(x'5c800041'),
(x'15ae43fd'),
(x'5d4cccfb'),
(x'4c800001'),
(x'57800ed8'),
(x'5f000000'),
(x'700000f0'),
(x'5f23e9ac'),
(x'5e9502f9'),
(x'5e8012b1'),
(x'3c000028'),
(x'60cde861'),
(x'03aa2a50'),
(x'43480000'),
(x'4c000000'),
-- LooksLikePow5
(x'5D1502F9'),
(x'5D9502F9'),
(x'5E1502F9'),
-- OutputLength
(x'3f99999a'),
(x'3f9d70a4'),
(x'3f9df3b6'),
(x'3f9e0419'),
(x'3f9e0610'),
(x'3f9e064b'),
(x'3f9e0651'),
(x'03d20cfe')
)
select float4send(flt) as ibits,
flt,
flt::text::float4 as r_flt,
float4send(flt::text::float4) as obits,
float4send(flt::text::float4) = float4send(flt) as correct
from (select bits::integer::xfloat4::float4 as flt
from testdata
offset 0) s;
ibits | flt | r_flt | obits | correct
------------+----------------+----------------+------------+---------
\x00000000 | 0 | 0 | \x00000000 | t
\x00800000 | 1.1754944e-38 | 1.1754944e-38 | \x00800000 | t
\x00800001 | 1.1754945e-38 | 1.1754945e-38 | \x00800001 | t
\x00800004 | 1.1754949e-38 | 1.1754949e-38 | \x00800004 | t
\x00800005 | 1.175495e-38 | 1.175495e-38 | \x00800005 | t
\x00800006 | 1.1754952e-38 | 1.1754952e-38 | \x00800006 | t
\x008002f1 | 1.1755999e-38 | 1.1755999e-38 | \x008002f1 | t
\x008002f2 | 1.1756e-38 | 1.1756e-38 | \x008002f2 | t
\x008002f3 | 1.1756001e-38 | 1.1756001e-38 | \x008002f3 | t
\x00800e17 | 1.1759998e-38 | 1.1759998e-38 | \x00800e17 | t
\x00800e18 | 1.176e-38 | 1.176e-38 | \x00800e18 | t
\x00800e19 | 1.1760001e-38 | 1.1760001e-38 | \x00800e19 | t
\x01000001 | 2.350989e-38 | 2.350989e-38 | \x01000001 | t
\x01102843 | 2.647751e-38 | 2.647751e-38 | \x01102843 | t
\x01a52c98 | 6.0675416e-38 | 6.0675416e-38 | \x01a52c98 | t
\x0219c229 | 1.1296386e-37 | 1.1296386e-37 | \x0219c229 | t
\x02e4464d | 3.354194e-37 | 3.354194e-37 | \x02e4464d | t
\x037343c1 | 7.148906e-37 | 7.148906e-37 | \x037343c1 | t
\x03a91b36 | 9.939175e-37 | 9.939175e-37 | \x03a91b36 | t
\x047ada65 | 2.948764e-36 | 2.948764e-36 | \x047ada65 | t
\x0496fe87 | 3.5498577e-36 | 3.5498577e-36 | \x0496fe87 | t
\x0550844f | 9.804414e-36 | 9.804414e-36 | \x0550844f | t
\x05999da3 | 1.4445957e-35 | 1.4445957e-35 | \x05999da3 | t
\x060ea5e2 | 2.6829103e-35 | 2.6829103e-35 | \x060ea5e2 | t
\x06e63c45 | 8.660494e-35 | 8.660494e-35 | \x06e63c45 | t
\x07f1e548 | 3.639641e-34 | 3.639641e-34 | \x07f1e548 | t
\x0fc5282b | 1.9441172e-29 | 1.9441172e-29 | \x0fc5282b | t
\x1f850283 | 5.6331846e-20 | 5.6331846e-20 | \x1f850283 | t
\x2874a9d6 | 1.3581548e-14 | 1.3581548e-14 | \x2874a9d6 | t
\x3356bf94 | 4.9999997e-08 | 4.9999997e-08 | \x3356bf94 | t
\x3356bf95 | 5e-08 | 5e-08 | \x3356bf95 | t
\x3356bf96 | 5.0000004e-08 | 5.0000004e-08 | \x3356bf96 | t
\x33d6bf94 | 9.9999994e-08 | 9.9999994e-08 | \x33d6bf94 | t
\x33d6bf95 | 1e-07 | 1e-07 | \x33d6bf95 | t
\x33d6bf96 | 1.0000001e-07 | 1.0000001e-07 | \x33d6bf96 | t
\x34a10faf | 2.9999998e-07 | 2.9999998e-07 | \x34a10faf | t
\x34a10fb0 | 3e-07 | 3e-07 | \x34a10fb0 | t
\x34a10fb1 | 3.0000004e-07 | 3.0000004e-07 | \x34a10fb1 | t
\x350637bc | 4.9999994e-07 | 4.9999994e-07 | \x350637bc | t
\x350637bd | 5e-07 | 5e-07 | \x350637bd | t
\x350637be | 5.0000006e-07 | 5.0000006e-07 | \x350637be | t
\x35719786 | 8.999999e-07 | 8.999999e-07 | \x35719786 | t
\x35719787 | 9e-07 | 9e-07 | \x35719787 | t
\x35719788 | 9.0000003e-07 | 9.0000003e-07 | \x35719788 | t
\x358637bc | 9.999999e-07 | 9.999999e-07 | \x358637bc | t
\x358637bd | 1e-06 | 1e-06 | \x358637bd | t
\x358637be | 1.0000001e-06 | 1.0000001e-06 | \x358637be | t
\x36a7c5ab | 4.9999994e-06 | 4.9999994e-06 | \x36a7c5ab | t
\x36a7c5ac | 5e-06 | 5e-06 | \x36a7c5ac | t
\x36a7c5ad | 5.0000003e-06 | 5.0000003e-06 | \x36a7c5ad | t
\x3727c5ab | 9.999999e-06 | 9.999999e-06 | \x3727c5ab | t
\x3727c5ac | 1e-05 | 1e-05 | \x3727c5ac | t
\x3727c5ad | 1.0000001e-05 | 1.0000001e-05 | \x3727c5ad | t
\x38d1b714 | 9.9999976e-05 | 9.9999976e-05 | \x38d1b714 | t
\x38d1b715 | 9.999998e-05 | 9.999998e-05 | \x38d1b715 | t
\x38d1b716 | 9.999999e-05 | 9.999999e-05 | \x38d1b716 | t
\x38d1b717 | 0.0001 | 0.0001 | \x38d1b717 | t
\x38d1b718 | 0.000100000005 | 0.000100000005 | \x38d1b718 | t
\x38d1b719 | 0.00010000001 | 0.00010000001 | \x38d1b719 | t
\x38d1b71a | 0.00010000002 | 0.00010000002 | \x38d1b71a | t
\x38d1b71b | 0.00010000003 | 0.00010000003 | \x38d1b71b | t
\x38d1b71c | 0.000100000034 | 0.000100000034 | \x38d1b71c | t
\x38d1b71d | 0.00010000004 | 0.00010000004 | \x38d1b71d | t
\x38dffffe | 0.00010681151 | 0.00010681151 | \x38dffffe | t
\x38dfffff | 0.000106811516 | 0.000106811516 | \x38dfffff | t
\x38e00000 | 0.00010681152 | 0.00010681152 | \x38e00000 | t
\x38efffff | 0.00011444091 | 0.00011444091 | \x38efffff | t
\x38f00000 | 0.00011444092 | 0.00011444092 | \x38f00000 | t
\x38f00001 | 0.000114440925 | 0.000114440925 | \x38f00001 | t
\x3a83126e | 0.0009999999 | 0.0009999999 | \x3a83126e | t
\x3a83126f | 0.001 | 0.001 | \x3a83126f | t
\x3a831270 | 0.0010000002 | 0.0010000002 | \x3a831270 | t
\x3c23d709 | 0.009999999 | 0.009999999 | \x3c23d709 | t
\x3c23d70a | 0.01 | 0.01 | \x3c23d70a | t
\x3c23d70b | 0.010000001 | 0.010000001 | \x3c23d70b | t
\x3dcccccc | 0.099999994 | 0.099999994 | \x3dcccccc | t
\x3dcccccd | 0.1 | 0.1 | \x3dcccccd | t
\x3dccccce | 0.10000001 | 0.10000001 | \x3dccccce | t
\x3dcccd6f | 0.10000121 | 0.10000121 | \x3dcccd6f | t
\x3dcccd70 | 0.100001216 | 0.100001216 | \x3dcccd70 | t
\x3dcccd71 | 0.10000122 | 0.10000122 | \x3dcccd71 | t
\x3effffff | 0.49999997 | 0.49999997 | \x3effffff | t
\x3f000000 | 0.5 | 0.5 | \x3f000000 | t
\x3f000001 | 0.50000006 | 0.50000006 | \x3f000001 | t
\x3f333332 | 0.6999999 | 0.6999999 | \x3f333332 | t
\x3f333333 | 0.7 | 0.7 | \x3f333333 | t
\x3f333334 | 0.70000005 | 0.70000005 | \x3f333334 | t
\x3f666665 | 0.8999999 | 0.8999999 | \x3f666665 | t
\x3f666666 | 0.9 | 0.9 | \x3f666666 | t
\x3f666667 | 0.90000004 | 0.90000004 | \x3f666667 | t
\x3f7d70a3 | 0.98999995 | 0.98999995 | \x3f7d70a3 | t
\x3f7d70a4 | 0.99 | 0.99 | \x3f7d70a4 | t
\x3f7d70a5 | 0.99000007 | 0.99000007 | \x3f7d70a5 | t
\x3f7fbe76 | 0.99899995 | 0.99899995 | \x3f7fbe76 | t
\x3f7fbe77 | 0.999 | 0.999 | \x3f7fbe77 | t
\x3f7fbe78 | 0.9990001 | 0.9990001 | \x3f7fbe78 | t
\x3f7ff971 | 0.9998999 | 0.9998999 | \x3f7ff971 | t
\x3f7ff972 | 0.9999 | 0.9999 | \x3f7ff972 | t
\x3f7ff973 | 0.99990004 | 0.99990004 | \x3f7ff973 | t
\x3f7fff57 | 0.9999899 | 0.9999899 | \x3f7fff57 | t
\x3f7fff58 | 0.99999 | 0.99999 | \x3f7fff58 | t
\x3f7fff59 | 0.99999005 | 0.99999005 | \x3f7fff59 | t
\x3f7fffee | 0.9999989 | 0.9999989 | \x3f7fffee | t
\x3f7fffef | 0.999999 | 0.999999 | \x3f7fffef | t
\x3f7ffff0 | 0.99999905 | 0.99999905 | \x3f7ffff0 | t
\x3f7ffff1 | 0.9999991 | 0.9999991 | \x3f7ffff1 | t
\x3f7ffff2 | 0.99999917 | 0.99999917 | \x3f7ffff2 | t
\x3f7ffff3 | 0.9999992 | 0.9999992 | \x3f7ffff3 | t
\x3f7ffff4 | 0.9999993 | 0.9999993 | \x3f7ffff4 | t
\x3f7ffff5 | 0.99999934 | 0.99999934 | \x3f7ffff5 | t
\x3f7ffff6 | 0.9999994 | 0.9999994 | \x3f7ffff6 | t
\x3f7ffff7 | 0.99999946 | 0.99999946 | \x3f7ffff7 | t
\x3f7ffff8 | 0.9999995 | 0.9999995 | \x3f7ffff8 | t
\x3f7ffff9 | 0.9999996 | 0.9999996 | \x3f7ffff9 | t
\x3f7ffffa | 0.99999964 | 0.99999964 | \x3f7ffffa | t
\x3f7ffffb | 0.9999997 | 0.9999997 | \x3f7ffffb | t
\x3f7ffffc | 0.99999976 | 0.99999976 | \x3f7ffffc | t
\x3f7ffffd | 0.9999998 | 0.9999998 | \x3f7ffffd | t
\x3f7ffffe | 0.9999999 | 0.9999999 | \x3f7ffffe | t
\x3f7fffff | 0.99999994 | 0.99999994 | \x3f7fffff | t
\x3f800000 | 1 | 1 | \x3f800000 | t
\x3f800001 | 1.0000001 | 1.0000001 | \x3f800001 | t
\x3f800002 | 1.0000002 | 1.0000002 | \x3f800002 | t
\x3f800003 | 1.0000004 | 1.0000004 | \x3f800003 | t
\x3f800004 | 1.0000005 | 1.0000005 | \x3f800004 | t
\x3f800005 | 1.0000006 | 1.0000006 | \x3f800005 | t
\x3f800006 | 1.0000007 | 1.0000007 | \x3f800006 | t
\x3f800007 | 1.0000008 | 1.0000008 | \x3f800007 | t
\x3f800008 | 1.000001 | 1.000001 | \x3f800008 | t
\x3f800009 | 1.0000011 | 1.0000011 | \x3f800009 | t
\x3f80000f | 1.0000018 | 1.0000018 | \x3f80000f | t
\x3f800010 | 1.0000019 | 1.0000019 | \x3f800010 | t
\x3f800011 | 1.000002 | 1.000002 | \x3f800011 | t
\x3f800012 | 1.0000021 | 1.0000021 | \x3f800012 | t
\x3f800013 | 1.0000023 | 1.0000023 | \x3f800013 | t
\x3f800014 | 1.0000024 | 1.0000024 | \x3f800014 | t
\x3f800017 | 1.0000027 | 1.0000027 | \x3f800017 | t
\x3f800018 | 1.0000029 | 1.0000029 | \x3f800018 | t
\x3f800019 | 1.000003 | 1.000003 | \x3f800019 | t
\x3f80001a | 1.0000031 | 1.0000031 | \x3f80001a | t
\x3f80001b | 1.0000032 | 1.0000032 | \x3f80001b | t
\x3f80001c | 1.0000033 | 1.0000033 | \x3f80001c | t
\x3f800029 | 1.0000049 | 1.0000049 | \x3f800029 | t
\x3f80002a | 1.000005 | 1.000005 | \x3f80002a | t
\x3f80002b | 1.0000051 | 1.0000051 | \x3f80002b | t
\x3f800053 | 1.0000099 | 1.0000099 | \x3f800053 | t
\x3f800054 | 1.00001 | 1.00001 | \x3f800054 | t
\x3f800055 | 1.0000101 | 1.0000101 | \x3f800055 | t
\x3f800346 | 1.0000999 | 1.0000999 | \x3f800346 | t
\x3f800347 | 1.0001 | 1.0001 | \x3f800347 | t
\x3f800348 | 1.0001001 | 1.0001001 | \x3f800348 | t
\x3f8020c4 | 1.0009999 | 1.0009999 | \x3f8020c4 | t
\x3f8020c5 | 1.001 | 1.001 | \x3f8020c5 | t
\x3f8020c6 | 1.0010002 | 1.0010002 | \x3f8020c6 | t
\x3f8147ad | 1.0099999 | 1.0099999 | \x3f8147ad | t
\x3f8147ae | 1.01 | 1.01 | \x3f8147ae | t
\x3f8147af | 1.0100001 | 1.0100001 | \x3f8147af | t
\x3f8ccccc | 1.0999999 | 1.0999999 | \x3f8ccccc | t
\x3f8ccccd | 1.1 | 1.1 | \x3f8ccccd | t
\x3f8cccce | 1.1000001 | 1.1000001 | \x3f8cccce | t
\x3fc90fdb | 1.5707964 | 1.5707964 | \x3fc90fdb | t
\x402df854 | 2.7182817 | 2.7182817 | \x402df854 | t
\x40490fdb | 3.1415927 | 3.1415927 | \x40490fdb | t
\x409fffff | 4.9999995 | 4.9999995 | \x409fffff | t
\x40a00000 | 5 | 5 | \x40a00000 | t
\x40a00001 | 5.0000005 | 5.0000005 | \x40a00001 | t
\x40afffff | 5.4999995 | 5.4999995 | \x40afffff | t
\x40b00000 | 5.5 | 5.5 | \x40b00000 | t
\x40b00001 | 5.5000005 | 5.5000005 | \x40b00001 | t
\x411fffff | 9.999999 | 9.999999 | \x411fffff | t
\x41200000 | 10 | 10 | \x41200000 | t
\x41200001 | 10.000001 | 10.000001 | \x41200001 | t
\x42c7ffff | 99.99999 | 99.99999 | \x42c7ffff | t
\x42c80000 | 100 | 100 | \x42c80000 | t
\x42c80001 | 100.00001 | 100.00001 | \x42c80001 | t
\x4479ffff | 999.99994 | 999.99994 | \x4479ffff | t
\x447a0000 | 1000 | 1000 | \x447a0000 | t
\x447a0001 | 1000.00006 | 1000.00006 | \x447a0001 | t
\x461c3fff | 9999.999 | 9999.999 | \x461c3fff | t
\x461c4000 | 10000 | 10000 | \x461c4000 | t
\x461c4001 | 10000.001 | 10000.001 | \x461c4001 | t
\x47c34fff | 99999.99 | 99999.99 | \x47c34fff | t
\x47c35000 | 100000 | 100000 | \x47c35000 | t
\x47c35001 | 100000.01 | 100000.01 | \x47c35001 | t
\x497423ff | 999999.94 | 999999.94 | \x497423ff | t
\x49742400 | 1e+06 | 1e+06 | \x49742400 | t
\x49742401 | 1.00000006e+06 | 1.00000006e+06 | \x49742401 | t
\x4b18967f | 9.999999e+06 | 9.999999e+06 | \x4b18967f | t
\x4b189680 | 1e+07 | 1e+07 | \x4b189680 | t
\x4b189681 | 1.0000001e+07 | 1.0000001e+07 | \x4b189681 | t
\x4cbebc1f | 9.999999e+07 | 9.999999e+07 | \x4cbebc1f | t
\x4cbebc20 | 1e+08 | 1e+08 | \x4cbebc20 | t
\x4cbebc21 | 1.0000001e+08 | 1.0000001e+08 | \x4cbebc21 | t
\x4e6e6b27 | 9.9999994e+08 | 9.9999994e+08 | \x4e6e6b27 | t
\x4e6e6b28 | 1e+09 | 1e+09 | \x4e6e6b28 | t
\x4e6e6b29 | 1.00000006e+09 | 1.00000006e+09 | \x4e6e6b29 | t
\x501502f8 | 9.999999e+09 | 9.999999e+09 | \x501502f8 | t
\x501502f9 | 1e+10 | 1e+10 | \x501502f9 | t
\x501502fa | 1.0000001e+10 | 1.0000001e+10 | \x501502fa | t
\x51ba43b6 | 9.999999e+10 | 9.999999e+10 | \x51ba43b6 | t
\x51ba43b7 | 1e+11 | 1e+11 | \x51ba43b7 | t
\x51ba43b8 | 1.0000001e+11 | 1.0000001e+11 | \x51ba43b8 | t
\x1f6c1e4a | 5e-20 | 5e-20 | \x1f6c1e4a | t
\x59be6cea | 6.7e+15 | 6.7e+15 | \x59be6cea | t
\x5d5ab6c4 | 9.85e+17 | 9.85e+17 | \x5d5ab6c4 | t
\x2cc4a9bd | 5.5895e-12 | 5.5895e-12 | \x2cc4a9bd | t
\x15ae43fd | 7.038531e-26 | 7.0385313e-26 | \x15ae43fe | f
\x2cf757ca | 7.0299088e-12 | 7.0299088e-12 | \x2cf757ca | t
\x665ba998 | 2.5933168e+23 | 2.5933168e+23 | \x665ba998 | t
\x743c3324 | 5.9642887e+31 | 5.9642887e+31 | \x743c3324 | t
\x47f1205a | 123456.7 | 123456.7 | \x47f1205a | t
\x4640e6ae | 12345.67 | 12345.67 | \x4640e6ae | t
\x449a5225 | 1234.567 | 1234.567 | \x449a5225 | t
\x42f6e9d5 | 123.4567 | 123.4567 | \x42f6e9d5 | t
\x414587dd | 12.34567 | 12.34567 | \x414587dd | t
\x3f9e064b | 1.234567 | 1.234567 | \x3f9e064b | t
\x4c000004 | 3.3554448e+07 | 3.3554448e+07 | \x4c000004 | t
\x50061c46 | 8.999999e+09 | 8.999999e+09 | \x50061c46 | t
\x510006a8 | 3.4366718e+10 | 3.4366718e+10 | \x510006a8 | t
\x48951f84 | 305404.12 | 305404.12 | \x48951f84 | t
\x45fd1840 | 8099.0312 | 8099.0312 | \x45fd1840 | t
\x39800000 | 0.00024414062 | 0.00024414062 | \x39800000 | t
\x3b200000 | 0.0024414062 | 0.0024414062 | \x3b200000 | t
\x3b900000 | 0.0043945312 | 0.0043945312 | \x3b900000 | t
\x3bd00000 | 0.0063476562 | 0.0063476562 | \x3bd00000 | t
\x63800000 | 4.7223665e+21 | 4.7223665e+21 | \x63800000 | t
\x4b000000 | 8.388608e+06 | 8.388608e+06 | \x4b000000 | t
\x4b800000 | 1.6777216e+07 | 1.6777216e+07 | \x4b800000 | t
\x4c000001 | 3.3554436e+07 | 3.3554436e+07 | \x4c000001 | t
\x4c800b0d | 6.7131496e+07 | 6.7131496e+07 | \x4c800b0d | t
\x00d24584 | 1.9310392e-38 | 1.9310392e-38 | \x00d24584 | t
\x800000b0 | -2.47e-43 | -2.47e-43 | \x800000b0 | t
\x00d90b88 | 1.993244e-38 | 1.993244e-38 | \x00d90b88 | t
\x45803f34 | 4103.9004 | 4103.9004 | \x45803f34 | t
\x4f9f24f7 | 5.3399997e+09 | 5.3399997e+09 | \x4f9f24f7 | t
\x3a8722c3 | 0.0010310042 | 0.0010310042 | \x3a8722c3 | t
\x5c800041 | 2.882326e+17 | 2.882326e+17 | \x5c800041 | t
\x15ae43fd | 7.038531e-26 | 7.0385313e-26 | \x15ae43fe | f
\x5d4cccfb | 9.223404e+17 | 9.223404e+17 | \x5d4cccfb | t
\x4c800001 | 6.710887e+07 | 6.710887e+07 | \x4c800001 | t
\x57800ed8 | 2.816025e+14 | 2.816025e+14 | \x57800ed8 | t
\x5f000000 | 9.223372e+18 | 9.223372e+18 | \x5f000000 | t
\x700000f0 | 1.5846086e+29 | 1.5846086e+29 | \x700000f0 | t
\x5f23e9ac | 1.1811161e+19 | 1.1811161e+19 | \x5f23e9ac | t
\x5e9502f9 | 5.368709e+18 | 5.368709e+18 | \x5e9502f9 | t
\x5e8012b1 | 4.6143166e+18 | 4.6143166e+18 | \x5e8012b1 | t
\x3c000028 | 0.007812537 | 0.007812537 | \x3c000028 | t
\x60cde861 | 1.18697725e+20 | 1.18697725e+20 | \x60cde861 | t
\x03aa2a50 | 1.00014165e-36 | 1.00014165e-36 | \x03aa2a50 | t
\x43480000 | 200 | 200 | \x43480000 | t
\x4c000000 | 3.3554432e+07 | 3.3554432e+07 | \x4c000000 | t
\x5d1502f9 | 6.7108864e+17 | 6.7108864e+17 | \x5d1502f9 | t
\x5d9502f9 | 1.3421773e+18 | 1.3421773e+18 | \x5d9502f9 | t
\x5e1502f9 | 2.6843546e+18 | 2.6843546e+18 | \x5e1502f9 | t
\x3f99999a | 1.2 | 1.2 | \x3f99999a | t
\x3f9d70a4 | 1.23 | 1.23 | \x3f9d70a4 | t
\x3f9df3b6 | 1.234 | 1.234 | \x3f9df3b6 | t
\x3f9e0419 | 1.2345 | 1.2345 | \x3f9e0419 | t
\x3f9e0610 | 1.23456 | 1.23456 | \x3f9e0610 | t
\x3f9e064b | 1.234567 | 1.234567 | \x3f9e064b | t
\x3f9e0651 | 1.2345678 | 1.2345678 | \x3f9e0651 | t
\x03d20cfe | 1.23456735e-36 | 1.23456735e-36 | \x03d20cfe | t
(262 rows)
-- clean up, lest opr_sanity complain
\set VERBOSITY terse
drop type xfloat4 cascade;
NOTICE: drop cascades to 6 other objects
\set VERBOSITY default
--

View File

@ -142,22 +142,22 @@ SELECT 'nan'::numeric::float4;
(1 row)
SELECT '' AS five, * FROM FLOAT4_TBL;
five | f1
------+-------------
| 0
| 1004.3
| -34.84
| 1.23457e+20
| 1.23457e-20
five | f1
------+---------------
| 0
| 1004.3
| -34.84
| 1.2345679e+20
| 1.2345679e-20
(5 rows)
SELECT '' AS four, f.* FROM FLOAT4_TBL f WHERE f.f1 <> '1004.3';
four | f1
------+-------------
| 0
| -34.84
| 1.23457e+20
| 1.23457e-20
four | f1
------+---------------
| 0
| -34.84
| 1.2345679e+20
| 1.2345679e-20
(4 rows)
SELECT '' AS one, f.* FROM FLOAT4_TBL f WHERE f.f1 = '1004.3';
@ -167,110 +167,110 @@ SELECT '' AS one, f.* FROM FLOAT4_TBL f WHERE f.f1 = '1004.3';
(1 row)
SELECT '' AS three, f.* FROM FLOAT4_TBL f WHERE '1004.3' > f.f1;
three | f1
-------+-------------
| 0
| -34.84
| 1.23457e-20
three | f1
-------+---------------
| 0
| -34.84
| 1.2345679e-20
(3 rows)
SELECT '' AS three, f.* FROM FLOAT4_TBL f WHERE f.f1 < '1004.3';
three | f1
-------+-------------
| 0
| -34.84
| 1.23457e-20
three | f1
-------+---------------
| 0
| -34.84
| 1.2345679e-20
(3 rows)
SELECT '' AS four, f.* FROM FLOAT4_TBL f WHERE '1004.3' >= f.f1;
four | f1
------+-------------
| 0
| 1004.3
| -34.84
| 1.23457e-20
four | f1
------+---------------
| 0
| 1004.3
| -34.84
| 1.2345679e-20
(4 rows)
SELECT '' AS four, f.* FROM FLOAT4_TBL f WHERE f.f1 <= '1004.3';
four | f1
------+-------------
| 0
| 1004.3
| -34.84
| 1.23457e-20
four | f1
------+---------------
| 0
| 1004.3
| -34.84
| 1.2345679e-20
(4 rows)
SELECT '' AS three, f.f1, f.f1 * '-10' AS x FROM FLOAT4_TBL f
WHERE f.f1 > '0.0';
three | f1 | x
-------+-------------+--------------
| 1004.3 | -10043
| 1.23457e+20 | -1.23457e+21
| 1.23457e-20 | -1.23457e-19
three | f1 | x
-------+---------------+----------------
| 1004.3 | -10043
| 1.2345679e+20 | -1.2345678e+21
| 1.2345679e-20 | -1.2345678e-19
(3 rows)
SELECT '' AS three, f.f1, f.f1 + '-10' AS x FROM FLOAT4_TBL f
WHERE f.f1 > '0.0';
three | f1 | x
-------+-------------+-------------
| 1004.3 | 994.3
| 1.23457e+20 | 1.23457e+20
| 1.23457e-20 | -10
three | f1 | x
-------+---------------+---------------
| 1004.3 | 994.3
| 1.2345679e+20 | 1.2345679e+20
| 1.2345679e-20 | -10
(3 rows)
SELECT '' AS three, f.f1, f.f1 / '-10' AS x FROM FLOAT4_TBL f
WHERE f.f1 > '0.0';
three | f1 | x
-------+-------------+--------------
| 1004.3 | -100.43
| 1.23457e+20 | -1.23457e+19
| 1.23457e-20 | -1.23457e-21
three | f1 | x
-------+---------------+----------------
| 1004.3 | -100.43
| 1.2345679e+20 | -1.2345679e+19
| 1.2345679e-20 | -1.2345679e-21
(3 rows)
SELECT '' AS three, f.f1, f.f1 - '-10' AS x FROM FLOAT4_TBL f
WHERE f.f1 > '0.0';
three | f1 | x
-------+-------------+-------------
| 1004.3 | 1014.3
| 1.23457e+20 | 1.23457e+20
| 1.23457e-20 | 10
three | f1 | x
-------+---------------+---------------
| 1004.3 | 1014.3
| 1.2345679e+20 | 1.2345679e+20
| 1.2345679e-20 | 10
(3 rows)
-- test divide by zero
SELECT '' AS bad, f.f1 / '0.0' from FLOAT4_TBL f;
ERROR: division by zero
SELECT '' AS five, * FROM FLOAT4_TBL;
five | f1
------+-------------
| 0
| 1004.3
| -34.84
| 1.23457e+20
| 1.23457e-20
five | f1
------+---------------
| 0
| 1004.3
| -34.84
| 1.2345679e+20
| 1.2345679e-20
(5 rows)
-- test the unary float4abs operator
SELECT '' AS five, f.f1, @f.f1 AS abs_f1 FROM FLOAT4_TBL f;
five | f1 | abs_f1
------+-------------+-------------
| 0 | 0
| 1004.3 | 1004.3
| -34.84 | 34.84
| 1.23457e+20 | 1.23457e+20
| 1.23457e-20 | 1.23457e-20
five | f1 | abs_f1
------+---------------+---------------
| 0 | 0
| 1004.3 | 1004.3
| -34.84 | 34.84
| 1.2345679e+20 | 1.2345679e+20
| 1.2345679e-20 | 1.2345679e-20
(5 rows)
UPDATE FLOAT4_TBL
SET f1 = FLOAT4_TBL.f1 * '-1'
WHERE FLOAT4_TBL.f1 > '0.0';
SELECT '' AS five, * FROM FLOAT4_TBL;
five | f1
------+--------------
| 0
| -34.84
| -1004.3
| -1.23457e+20
| -1.23457e-20
five | f1
------+----------------
| 0
| -34.84
| -1004.3
| -1.2345679e+20
| -1.2345679e-20
(5 rows)
-- test edge-case coercions to integer
@ -434,3 +434,507 @@ SELECT float4send('1.1754944e-38'::float4);
\x00800000
(1 row)
-- test output (and round-trip safety) of various values.
-- To ensure we're testing what we think we're testing, start with
-- float values specified by bit patterns (as a useful side effect,
-- this means we'll fail on non-IEEE platforms).
create type xfloat4;
create function xfloat4in(cstring) returns xfloat4 immutable strict
language internal as 'int4in';
NOTICE: return type xfloat4 is only a shell
create function xfloat4out(xfloat4) returns cstring immutable strict
language internal as 'int4out';
NOTICE: argument type xfloat4 is only a shell
create type xfloat4 (input = xfloat4in, output = xfloat4out, like = float4);
create cast (xfloat4 as float4) without function;
create cast (float4 as xfloat4) without function;
create cast (xfloat4 as integer) without function;
create cast (integer as xfloat4) without function;
-- float4: seeeeeee emmmmmmm mmmmmmmm mmmmmmmm
-- we don't care to assume the platform's strtod() handles subnormals
-- correctly; those are "use at your own risk". However we do test
-- subnormal outputs, since those are under our control.
with testdata(bits) as (values
-- small subnormals
(x'00000001'),
(x'00000002'), (x'00000003'),
(x'00000010'), (x'00000011'), (x'00000100'), (x'00000101'),
(x'00004000'), (x'00004001'), (x'00080000'), (x'00080001'),
-- stress values
(x'0053c4f4'), -- 7693e-42
(x'006c85c4'), -- 996622e-44
(x'0041ca76'), -- 60419369e-46
(x'004b7678'), -- 6930161142e-48
-- taken from upstream testsuite
(x'00000007'),
(x'00424fe2'),
-- borderline between subnormal and normal
(x'007ffff0'), (x'007ffff1'), (x'007ffffe'), (x'007fffff'))
select float4send(flt) as ibits,
flt
from (select bits::integer::xfloat4::float4 as flt
from testdata
offset 0) s;
ibits | flt
------------+---------------
\x00000001 | 1e-45
\x00000002 | 3e-45
\x00000003 | 4e-45
\x00000010 | 2.2e-44
\x00000011 | 2.4e-44
\x00000100 | 3.59e-43
\x00000101 | 3.6e-43
\x00004000 | 2.2959e-41
\x00004001 | 2.296e-41
\x00080000 | 7.34684e-40
\x00080001 | 7.34685e-40
\x0053c4f4 | 7.693e-39
\x006c85c4 | 9.96622e-39
\x0041ca76 | 6.041937e-39
\x004b7678 | 6.930161e-39
\x00000007 | 1e-44
\x00424fe2 | 6.0898e-39
\x007ffff0 | 1.1754921e-38
\x007ffff1 | 1.1754922e-38
\x007ffffe | 1.1754941e-38
\x007fffff | 1.1754942e-38
(21 rows)
with testdata(bits) as (values
(x'00000000'),
-- smallest normal values
(x'00800000'), (x'00800001'), (x'00800004'), (x'00800005'),
(x'00800006'),
-- small normal values chosen for short vs. long output
(x'008002f1'), (x'008002f2'), (x'008002f3'),
(x'00800e17'), (x'00800e18'), (x'00800e19'),
-- assorted values (random mantissae)
(x'01000001'), (x'01102843'), (x'01a52c98'),
(x'0219c229'), (x'02e4464d'), (x'037343c1'), (x'03a91b36'),
(x'047ada65'), (x'0496fe87'), (x'0550844f'), (x'05999da3'),
(x'060ea5e2'), (x'06e63c45'), (x'07f1e548'), (x'0fc5282b'),
(x'1f850283'), (x'2874a9d6'),
-- values around 5e-08
(x'3356bf94'), (x'3356bf95'), (x'3356bf96'),
-- around 1e-07
(x'33d6bf94'), (x'33d6bf95'), (x'33d6bf96'),
-- around 3e-07 .. 1e-04
(x'34a10faf'), (x'34a10fb0'), (x'34a10fb1'),
(x'350637bc'), (x'350637bd'), (x'350637be'),
(x'35719786'), (x'35719787'), (x'35719788'),
(x'358637bc'), (x'358637bd'), (x'358637be'),
(x'36a7c5ab'), (x'36a7c5ac'), (x'36a7c5ad'),
(x'3727c5ab'), (x'3727c5ac'), (x'3727c5ad'),
-- format crossover at 1e-04
(x'38d1b714'), (x'38d1b715'), (x'38d1b716'),
(x'38d1b717'), (x'38d1b718'), (x'38d1b719'),
(x'38d1b71a'), (x'38d1b71b'), (x'38d1b71c'),
(x'38d1b71d'),
--
(x'38dffffe'), (x'38dfffff'), (x'38e00000'),
(x'38efffff'), (x'38f00000'), (x'38f00001'),
(x'3a83126e'), (x'3a83126f'), (x'3a831270'),
(x'3c23d709'), (x'3c23d70a'), (x'3c23d70b'),
(x'3dcccccc'), (x'3dcccccd'), (x'3dccccce'),
-- chosen to need 9 digits for 3dcccd70
(x'3dcccd6f'), (x'3dcccd70'), (x'3dcccd71'),
--
(x'3effffff'), (x'3f000000'), (x'3f000001'),
(x'3f333332'), (x'3f333333'), (x'3f333334'),
-- approach 1.0 with increasing numbers of 9s
(x'3f666665'), (x'3f666666'), (x'3f666667'),
(x'3f7d70a3'), (x'3f7d70a4'), (x'3f7d70a5'),
(x'3f7fbe76'), (x'3f7fbe77'), (x'3f7fbe78'),
(x'3f7ff971'), (x'3f7ff972'), (x'3f7ff973'),
(x'3f7fff57'), (x'3f7fff58'), (x'3f7fff59'),
(x'3f7fffee'), (x'3f7fffef'),
-- values very close to 1
(x'3f7ffff0'), (x'3f7ffff1'), (x'3f7ffff2'),
(x'3f7ffff3'), (x'3f7ffff4'), (x'3f7ffff5'),
(x'3f7ffff6'), (x'3f7ffff7'), (x'3f7ffff8'),
(x'3f7ffff9'), (x'3f7ffffa'), (x'3f7ffffb'),
(x'3f7ffffc'), (x'3f7ffffd'), (x'3f7ffffe'),
(x'3f7fffff'),
(x'3f800000'),
(x'3f800001'), (x'3f800002'), (x'3f800003'),
(x'3f800004'), (x'3f800005'), (x'3f800006'),
(x'3f800007'), (x'3f800008'), (x'3f800009'),
-- values 1 to 1.1
(x'3f80000f'), (x'3f800010'), (x'3f800011'),
(x'3f800012'), (x'3f800013'), (x'3f800014'),
(x'3f800017'), (x'3f800018'), (x'3f800019'),
(x'3f80001a'), (x'3f80001b'), (x'3f80001c'),
(x'3f800029'), (x'3f80002a'), (x'3f80002b'),
(x'3f800053'), (x'3f800054'), (x'3f800055'),
(x'3f800346'), (x'3f800347'), (x'3f800348'),
(x'3f8020c4'), (x'3f8020c5'), (x'3f8020c6'),
(x'3f8147ad'), (x'3f8147ae'), (x'3f8147af'),
(x'3f8ccccc'), (x'3f8ccccd'), (x'3f8cccce'),
--
(x'3fc90fdb'), -- pi/2
(x'402df854'), -- e
(x'40490fdb'), -- pi
--
(x'409fffff'), (x'40a00000'), (x'40a00001'),
(x'40afffff'), (x'40b00000'), (x'40b00001'),
(x'411fffff'), (x'41200000'), (x'41200001'),
(x'42c7ffff'), (x'42c80000'), (x'42c80001'),
(x'4479ffff'), (x'447a0000'), (x'447a0001'),
(x'461c3fff'), (x'461c4000'), (x'461c4001'),
(x'47c34fff'), (x'47c35000'), (x'47c35001'),
(x'497423ff'), (x'49742400'), (x'49742401'),
(x'4b18967f'), (x'4b189680'), (x'4b189681'),
(x'4cbebc1f'), (x'4cbebc20'), (x'4cbebc21'),
(x'4e6e6b27'), (x'4e6e6b28'), (x'4e6e6b29'),
(x'501502f8'), (x'501502f9'), (x'501502fa'),
(x'51ba43b6'), (x'51ba43b7'), (x'51ba43b8'),
-- stress values
(x'1f6c1e4a'), -- 5e-20
(x'59be6cea'), -- 67e14
(x'5d5ab6c4'), -- 985e15
(x'2cc4a9bd'), -- 55895e-16
(x'15ae43fd'), -- 7038531e-32
(x'2cf757ca'), -- 702990899e-20
(x'665ba998'), -- 25933168707e13
(x'743c3324'), -- 596428896559e20
-- exercise fixed-point memmoves
(x'47f1205a'),
(x'4640e6ae'),
(x'449a5225'),
(x'42f6e9d5'),
(x'414587dd'),
(x'3f9e064b'),
-- these cases come from the upstream's testsuite
-- BoundaryRoundEven
(x'4c000004'),
(x'50061c46'),
(x'510006a8'),
-- ExactValueRoundEven
(x'48951f84'),
(x'45fd1840'),
-- LotsOfTrailingZeros
(x'39800000'),
(x'3b200000'),
(x'3b900000'),
(x'3bd00000'),
-- Regression
(x'63800000'),
(x'4b000000'),
(x'4b800000'),
(x'4c000001'),
(x'4c800b0d'),
(x'00d24584'),
(x'800000b0'),
(x'00d90b88'),
(x'45803f34'),
(x'4f9f24f7'),
(x'3a8722c3'),
(x'5c800041'),
(x'15ae43fd'),
(x'5d4cccfb'),
(x'4c800001'),
(x'57800ed8'),
(x'5f000000'),
(x'700000f0'),
(x'5f23e9ac'),
(x'5e9502f9'),
(x'5e8012b1'),
(x'3c000028'),
(x'60cde861'),
(x'03aa2a50'),
(x'43480000'),
(x'4c000000'),
-- LooksLikePow5
(x'5D1502F9'),
(x'5D9502F9'),
(x'5E1502F9'),
-- OutputLength
(x'3f99999a'),
(x'3f9d70a4'),
(x'3f9df3b6'),
(x'3f9e0419'),
(x'3f9e0610'),
(x'3f9e064b'),
(x'3f9e0651'),
(x'03d20cfe')
)
select float4send(flt) as ibits,
flt,
flt::text::float4 as r_flt,
float4send(flt::text::float4) as obits,
float4send(flt::text::float4) = float4send(flt) as correct
from (select bits::integer::xfloat4::float4 as flt
from testdata
offset 0) s;
ibits | flt | r_flt | obits | correct
------------+----------------+----------------+------------+---------
\x00000000 | 0 | 0 | \x00000000 | t
\x00800000 | 1.1754944e-38 | 1.1754944e-38 | \x00800000 | t
\x00800001 | 1.1754945e-38 | 1.1754945e-38 | \x00800001 | t
\x00800004 | 1.1754949e-38 | 1.1754949e-38 | \x00800004 | t
\x00800005 | 1.175495e-38 | 1.175495e-38 | \x00800005 | t
\x00800006 | 1.1754952e-38 | 1.1754952e-38 | \x00800006 | t
\x008002f1 | 1.1755999e-38 | 1.1755999e-38 | \x008002f1 | t
\x008002f2 | 1.1756e-38 | 1.1756e-38 | \x008002f2 | t
\x008002f3 | 1.1756001e-38 | 1.1756001e-38 | \x008002f3 | t
\x00800e17 | 1.1759998e-38 | 1.1759998e-38 | \x00800e17 | t
\x00800e18 | 1.176e-38 | 1.176e-38 | \x00800e18 | t
\x00800e19 | 1.1760001e-38 | 1.1760001e-38 | \x00800e19 | t
\x01000001 | 2.350989e-38 | 2.350989e-38 | \x01000001 | t
\x01102843 | 2.647751e-38 | 2.647751e-38 | \x01102843 | t
\x01a52c98 | 6.0675416e-38 | 6.0675416e-38 | \x01a52c98 | t
\x0219c229 | 1.1296386e-37 | 1.1296386e-37 | \x0219c229 | t
\x02e4464d | 3.354194e-37 | 3.354194e-37 | \x02e4464d | t
\x037343c1 | 7.148906e-37 | 7.148906e-37 | \x037343c1 | t
\x03a91b36 | 9.939175e-37 | 9.939175e-37 | \x03a91b36 | t
\x047ada65 | 2.948764e-36 | 2.948764e-36 | \x047ada65 | t
\x0496fe87 | 3.5498577e-36 | 3.5498577e-36 | \x0496fe87 | t
\x0550844f | 9.804414e-36 | 9.804414e-36 | \x0550844f | t
\x05999da3 | 1.4445957e-35 | 1.4445957e-35 | \x05999da3 | t
\x060ea5e2 | 2.6829103e-35 | 2.6829103e-35 | \x060ea5e2 | t
\x06e63c45 | 8.660494e-35 | 8.660494e-35 | \x06e63c45 | t
\x07f1e548 | 3.639641e-34 | 3.639641e-34 | \x07f1e548 | t
\x0fc5282b | 1.9441172e-29 | 1.9441172e-29 | \x0fc5282b | t
\x1f850283 | 5.6331846e-20 | 5.6331846e-20 | \x1f850283 | t
\x2874a9d6 | 1.3581548e-14 | 1.3581548e-14 | \x2874a9d6 | t
\x3356bf94 | 4.9999997e-08 | 4.9999997e-08 | \x3356bf94 | t
\x3356bf95 | 5e-08 | 5e-08 | \x3356bf95 | t
\x3356bf96 | 5.0000004e-08 | 5.0000004e-08 | \x3356bf96 | t
\x33d6bf94 | 9.9999994e-08 | 9.9999994e-08 | \x33d6bf94 | t
\x33d6bf95 | 1e-07 | 1e-07 | \x33d6bf95 | t
\x33d6bf96 | 1.0000001e-07 | 1.0000001e-07 | \x33d6bf96 | t
\x34a10faf | 2.9999998e-07 | 2.9999998e-07 | \x34a10faf | t
\x34a10fb0 | 3e-07 | 3e-07 | \x34a10fb0 | t
\x34a10fb1 | 3.0000004e-07 | 3.0000004e-07 | \x34a10fb1 | t
\x350637bc | 4.9999994e-07 | 4.9999994e-07 | \x350637bc | t
\x350637bd | 5e-07 | 5e-07 | \x350637bd | t
\x350637be | 5.0000006e-07 | 5.0000006e-07 | \x350637be | t
\x35719786 | 8.999999e-07 | 8.999999e-07 | \x35719786 | t
\x35719787 | 9e-07 | 9e-07 | \x35719787 | t
\x35719788 | 9.0000003e-07 | 9.0000003e-07 | \x35719788 | t
\x358637bc | 9.999999e-07 | 9.999999e-07 | \x358637bc | t
\x358637bd | 1e-06 | 1e-06 | \x358637bd | t
\x358637be | 1.0000001e-06 | 1.0000001e-06 | \x358637be | t
\x36a7c5ab | 4.9999994e-06 | 4.9999994e-06 | \x36a7c5ab | t
\x36a7c5ac | 5e-06 | 5e-06 | \x36a7c5ac | t
\x36a7c5ad | 5.0000003e-06 | 5.0000003e-06 | \x36a7c5ad | t
\x3727c5ab | 9.999999e-06 | 9.999999e-06 | \x3727c5ab | t
\x3727c5ac | 1e-05 | 1e-05 | \x3727c5ac | t
\x3727c5ad | 1.0000001e-05 | 1.0000001e-05 | \x3727c5ad | t
\x38d1b714 | 9.9999976e-05 | 9.9999976e-05 | \x38d1b714 | t
\x38d1b715 | 9.999998e-05 | 9.999998e-05 | \x38d1b715 | t
\x38d1b716 | 9.999999e-05 | 9.999999e-05 | \x38d1b716 | t
\x38d1b717 | 0.0001 | 0.0001 | \x38d1b717 | t
\x38d1b718 | 0.000100000005 | 0.000100000005 | \x38d1b718 | t
\x38d1b719 | 0.00010000001 | 0.00010000001 | \x38d1b719 | t
\x38d1b71a | 0.00010000002 | 0.00010000002 | \x38d1b71a | t
\x38d1b71b | 0.00010000003 | 0.00010000003 | \x38d1b71b | t
\x38d1b71c | 0.000100000034 | 0.000100000034 | \x38d1b71c | t
\x38d1b71d | 0.00010000004 | 0.00010000004 | \x38d1b71d | t
\x38dffffe | 0.00010681151 | 0.00010681151 | \x38dffffe | t
\x38dfffff | 0.000106811516 | 0.000106811516 | \x38dfffff | t
\x38e00000 | 0.00010681152 | 0.00010681152 | \x38e00000 | t
\x38efffff | 0.00011444091 | 0.00011444091 | \x38efffff | t
\x38f00000 | 0.00011444092 | 0.00011444092 | \x38f00000 | t
\x38f00001 | 0.000114440925 | 0.000114440925 | \x38f00001 | t
\x3a83126e | 0.0009999999 | 0.0009999999 | \x3a83126e | t
\x3a83126f | 0.001 | 0.001 | \x3a83126f | t
\x3a831270 | 0.0010000002 | 0.0010000002 | \x3a831270 | t
\x3c23d709 | 0.009999999 | 0.009999999 | \x3c23d709 | t
\x3c23d70a | 0.01 | 0.01 | \x3c23d70a | t
\x3c23d70b | 0.010000001 | 0.010000001 | \x3c23d70b | t
\x3dcccccc | 0.099999994 | 0.099999994 | \x3dcccccc | t
\x3dcccccd | 0.1 | 0.1 | \x3dcccccd | t
\x3dccccce | 0.10000001 | 0.10000001 | \x3dccccce | t
\x3dcccd6f | 0.10000121 | 0.10000121 | \x3dcccd6f | t
\x3dcccd70 | 0.100001216 | 0.100001216 | \x3dcccd70 | t
\x3dcccd71 | 0.10000122 | 0.10000122 | \x3dcccd71 | t
\x3effffff | 0.49999997 | 0.49999997 | \x3effffff | t
\x3f000000 | 0.5 | 0.5 | \x3f000000 | t
\x3f000001 | 0.50000006 | 0.50000006 | \x3f000001 | t
\x3f333332 | 0.6999999 | 0.6999999 | \x3f333332 | t
\x3f333333 | 0.7 | 0.7 | \x3f333333 | t
\x3f333334 | 0.70000005 | 0.70000005 | \x3f333334 | t
\x3f666665 | 0.8999999 | 0.8999999 | \x3f666665 | t
\x3f666666 | 0.9 | 0.9 | \x3f666666 | t
\x3f666667 | 0.90000004 | 0.90000004 | \x3f666667 | t
\x3f7d70a3 | 0.98999995 | 0.98999995 | \x3f7d70a3 | t
\x3f7d70a4 | 0.99 | 0.99 | \x3f7d70a4 | t
\x3f7d70a5 | 0.99000007 | 0.99000007 | \x3f7d70a5 | t
\x3f7fbe76 | 0.99899995 | 0.99899995 | \x3f7fbe76 | t
\x3f7fbe77 | 0.999 | 0.999 | \x3f7fbe77 | t
\x3f7fbe78 | 0.9990001 | 0.9990001 | \x3f7fbe78 | t
\x3f7ff971 | 0.9998999 | 0.9998999 | \x3f7ff971 | t
\x3f7ff972 | 0.9999 | 0.9999 | \x3f7ff972 | t
\x3f7ff973 | 0.99990004 | 0.99990004 | \x3f7ff973 | t
\x3f7fff57 | 0.9999899 | 0.9999899 | \x3f7fff57 | t
\x3f7fff58 | 0.99999 | 0.99999 | \x3f7fff58 | t
\x3f7fff59 | 0.99999005 | 0.99999005 | \x3f7fff59 | t
\x3f7fffee | 0.9999989 | 0.9999989 | \x3f7fffee | t
\x3f7fffef | 0.999999 | 0.999999 | \x3f7fffef | t
\x3f7ffff0 | 0.99999905 | 0.99999905 | \x3f7ffff0 | t
\x3f7ffff1 | 0.9999991 | 0.9999991 | \x3f7ffff1 | t
\x3f7ffff2 | 0.99999917 | 0.99999917 | \x3f7ffff2 | t
\x3f7ffff3 | 0.9999992 | 0.9999992 | \x3f7ffff3 | t
\x3f7ffff4 | 0.9999993 | 0.9999993 | \x3f7ffff4 | t
\x3f7ffff5 | 0.99999934 | 0.99999934 | \x3f7ffff5 | t
\x3f7ffff6 | 0.9999994 | 0.9999994 | \x3f7ffff6 | t
\x3f7ffff7 | 0.99999946 | 0.99999946 | \x3f7ffff7 | t
\x3f7ffff8 | 0.9999995 | 0.9999995 | \x3f7ffff8 | t
\x3f7ffff9 | 0.9999996 | 0.9999996 | \x3f7ffff9 | t
\x3f7ffffa | 0.99999964 | 0.99999964 | \x3f7ffffa | t
\x3f7ffffb | 0.9999997 | 0.9999997 | \x3f7ffffb | t
\x3f7ffffc | 0.99999976 | 0.99999976 | \x3f7ffffc | t
\x3f7ffffd | 0.9999998 | 0.9999998 | \x3f7ffffd | t
\x3f7ffffe | 0.9999999 | 0.9999999 | \x3f7ffffe | t
\x3f7fffff | 0.99999994 | 0.99999994 | \x3f7fffff | t
\x3f800000 | 1 | 1 | \x3f800000 | t
\x3f800001 | 1.0000001 | 1.0000001 | \x3f800001 | t
\x3f800002 | 1.0000002 | 1.0000002 | \x3f800002 | t
\x3f800003 | 1.0000004 | 1.0000004 | \x3f800003 | t
\x3f800004 | 1.0000005 | 1.0000005 | \x3f800004 | t
\x3f800005 | 1.0000006 | 1.0000006 | \x3f800005 | t
\x3f800006 | 1.0000007 | 1.0000007 | \x3f800006 | t
\x3f800007 | 1.0000008 | 1.0000008 | \x3f800007 | t
\x3f800008 | 1.000001 | 1.000001 | \x3f800008 | t
\x3f800009 | 1.0000011 | 1.0000011 | \x3f800009 | t
\x3f80000f | 1.0000018 | 1.0000018 | \x3f80000f | t
\x3f800010 | 1.0000019 | 1.0000019 | \x3f800010 | t
\x3f800011 | 1.000002 | 1.000002 | \x3f800011 | t
\x3f800012 | 1.0000021 | 1.0000021 | \x3f800012 | t
\x3f800013 | 1.0000023 | 1.0000023 | \x3f800013 | t
\x3f800014 | 1.0000024 | 1.0000024 | \x3f800014 | t
\x3f800017 | 1.0000027 | 1.0000027 | \x3f800017 | t
\x3f800018 | 1.0000029 | 1.0000029 | \x3f800018 | t
\x3f800019 | 1.000003 | 1.000003 | \x3f800019 | t
\x3f80001a | 1.0000031 | 1.0000031 | \x3f80001a | t
\x3f80001b | 1.0000032 | 1.0000032 | \x3f80001b | t
\x3f80001c | 1.0000033 | 1.0000033 | \x3f80001c | t
\x3f800029 | 1.0000049 | 1.0000049 | \x3f800029 | t
\x3f80002a | 1.000005 | 1.000005 | \x3f80002a | t
\x3f80002b | 1.0000051 | 1.0000051 | \x3f80002b | t
\x3f800053 | 1.0000099 | 1.0000099 | \x3f800053 | t
\x3f800054 | 1.00001 | 1.00001 | \x3f800054 | t
\x3f800055 | 1.0000101 | 1.0000101 | \x3f800055 | t
\x3f800346 | 1.0000999 | 1.0000999 | \x3f800346 | t
\x3f800347 | 1.0001 | 1.0001 | \x3f800347 | t
\x3f800348 | 1.0001001 | 1.0001001 | \x3f800348 | t
\x3f8020c4 | 1.0009999 | 1.0009999 | \x3f8020c4 | t
\x3f8020c5 | 1.001 | 1.001 | \x3f8020c5 | t
\x3f8020c6 | 1.0010002 | 1.0010002 | \x3f8020c6 | t
\x3f8147ad | 1.0099999 | 1.0099999 | \x3f8147ad | t
\x3f8147ae | 1.01 | 1.01 | \x3f8147ae | t
\x3f8147af | 1.0100001 | 1.0100001 | \x3f8147af | t
\x3f8ccccc | 1.0999999 | 1.0999999 | \x3f8ccccc | t
\x3f8ccccd | 1.1 | 1.1 | \x3f8ccccd | t
\x3f8cccce | 1.1000001 | 1.1000001 | \x3f8cccce | t
\x3fc90fdb | 1.5707964 | 1.5707964 | \x3fc90fdb | t
\x402df854 | 2.7182817 | 2.7182817 | \x402df854 | t
\x40490fdb | 3.1415927 | 3.1415927 | \x40490fdb | t
\x409fffff | 4.9999995 | 4.9999995 | \x409fffff | t
\x40a00000 | 5 | 5 | \x40a00000 | t
\x40a00001 | 5.0000005 | 5.0000005 | \x40a00001 | t
\x40afffff | 5.4999995 | 5.4999995 | \x40afffff | t
\x40b00000 | 5.5 | 5.5 | \x40b00000 | t
\x40b00001 | 5.5000005 | 5.5000005 | \x40b00001 | t
\x411fffff | 9.999999 | 9.999999 | \x411fffff | t
\x41200000 | 10 | 10 | \x41200000 | t
\x41200001 | 10.000001 | 10.000001 | \x41200001 | t
\x42c7ffff | 99.99999 | 99.99999 | \x42c7ffff | t
\x42c80000 | 100 | 100 | \x42c80000 | t
\x42c80001 | 100.00001 | 100.00001 | \x42c80001 | t
\x4479ffff | 999.99994 | 999.99994 | \x4479ffff | t
\x447a0000 | 1000 | 1000 | \x447a0000 | t
\x447a0001 | 1000.00006 | 1000.00006 | \x447a0001 | t
\x461c3fff | 9999.999 | 9999.999 | \x461c3fff | t
\x461c4000 | 10000 | 10000 | \x461c4000 | t
\x461c4001 | 10000.001 | 10000.001 | \x461c4001 | t
\x47c34fff | 99999.99 | 99999.99 | \x47c34fff | t
\x47c35000 | 100000 | 100000 | \x47c35000 | t
\x47c35001 | 100000.01 | 100000.01 | \x47c35001 | t
\x497423ff | 999999.94 | 999999.94 | \x497423ff | t
\x49742400 | 1e+06 | 1e+06 | \x49742400 | t
\x49742401 | 1.00000006e+06 | 1.00000006e+06 | \x49742401 | t
\x4b18967f | 9.999999e+06 | 9.999999e+06 | \x4b18967f | t
\x4b189680 | 1e+07 | 1e+07 | \x4b189680 | t
\x4b189681 | 1.0000001e+07 | 1.0000001e+07 | \x4b189681 | t
\x4cbebc1f | 9.999999e+07 | 9.999999e+07 | \x4cbebc1f | t
\x4cbebc20 | 1e+08 | 1e+08 | \x4cbebc20 | t
\x4cbebc21 | 1.0000001e+08 | 1.0000001e+08 | \x4cbebc21 | t
\x4e6e6b27 | 9.9999994e+08 | 9.9999994e+08 | \x4e6e6b27 | t
\x4e6e6b28 | 1e+09 | 1e+09 | \x4e6e6b28 | t
\x4e6e6b29 | 1.00000006e+09 | 1.00000006e+09 | \x4e6e6b29 | t
\x501502f8 | 9.999999e+09 | 9.999999e+09 | \x501502f8 | t
\x501502f9 | 1e+10 | 1e+10 | \x501502f9 | t
\x501502fa | 1.0000001e+10 | 1.0000001e+10 | \x501502fa | t
\x51ba43b6 | 9.999999e+10 | 9.999999e+10 | \x51ba43b6 | t
\x51ba43b7 | 1e+11 | 1e+11 | \x51ba43b7 | t
\x51ba43b8 | 1.0000001e+11 | 1.0000001e+11 | \x51ba43b8 | t
\x1f6c1e4a | 5e-20 | 5e-20 | \x1f6c1e4a | t
\x59be6cea | 6.7e+15 | 6.7e+15 | \x59be6cea | t
\x5d5ab6c4 | 9.85e+17 | 9.85e+17 | \x5d5ab6c4 | t
\x2cc4a9bd | 5.5895e-12 | 5.5895e-12 | \x2cc4a9bd | t
\x15ae43fd | 7.038531e-26 | 7.038531e-26 | \x15ae43fd | t
\x2cf757ca | 7.0299088e-12 | 7.0299088e-12 | \x2cf757ca | t
\x665ba998 | 2.5933168e+23 | 2.5933168e+23 | \x665ba998 | t
\x743c3324 | 5.9642887e+31 | 5.9642887e+31 | \x743c3324 | t
\x47f1205a | 123456.7 | 123456.7 | \x47f1205a | t
\x4640e6ae | 12345.67 | 12345.67 | \x4640e6ae | t
\x449a5225 | 1234.567 | 1234.567 | \x449a5225 | t
\x42f6e9d5 | 123.4567 | 123.4567 | \x42f6e9d5 | t
\x414587dd | 12.34567 | 12.34567 | \x414587dd | t
\x3f9e064b | 1.234567 | 1.234567 | \x3f9e064b | t
\x4c000004 | 3.3554448e+07 | 3.3554448e+07 | \x4c000004 | t
\x50061c46 | 8.999999e+09 | 8.999999e+09 | \x50061c46 | t
\x510006a8 | 3.4366718e+10 | 3.4366718e+10 | \x510006a8 | t
\x48951f84 | 305404.12 | 305404.12 | \x48951f84 | t
\x45fd1840 | 8099.0312 | 8099.0312 | \x45fd1840 | t
\x39800000 | 0.00024414062 | 0.00024414062 | \x39800000 | t
\x3b200000 | 0.0024414062 | 0.0024414062 | \x3b200000 | t
\x3b900000 | 0.0043945312 | 0.0043945312 | \x3b900000 | t
\x3bd00000 | 0.0063476562 | 0.0063476562 | \x3bd00000 | t
\x63800000 | 4.7223665e+21 | 4.7223665e+21 | \x63800000 | t
\x4b000000 | 8.388608e+06 | 8.388608e+06 | \x4b000000 | t
\x4b800000 | 1.6777216e+07 | 1.6777216e+07 | \x4b800000 | t
\x4c000001 | 3.3554436e+07 | 3.3554436e+07 | \x4c000001 | t
\x4c800b0d | 6.7131496e+07 | 6.7131496e+07 | \x4c800b0d | t
\x00d24584 | 1.9310392e-38 | 1.9310392e-38 | \x00d24584 | t
\x800000b0 | -2.47e-43 | -2.47e-43 | \x800000b0 | t
\x00d90b88 | 1.993244e-38 | 1.993244e-38 | \x00d90b88 | t
\x45803f34 | 4103.9004 | 4103.9004 | \x45803f34 | t
\x4f9f24f7 | 5.3399997e+09 | 5.3399997e+09 | \x4f9f24f7 | t
\x3a8722c3 | 0.0010310042 | 0.0010310042 | \x3a8722c3 | t
\x5c800041 | 2.882326e+17 | 2.882326e+17 | \x5c800041 | t
\x15ae43fd | 7.038531e-26 | 7.038531e-26 | \x15ae43fd | t
\x5d4cccfb | 9.223404e+17 | 9.223404e+17 | \x5d4cccfb | t
\x4c800001 | 6.710887e+07 | 6.710887e+07 | \x4c800001 | t
\x57800ed8 | 2.816025e+14 | 2.816025e+14 | \x57800ed8 | t
\x5f000000 | 9.223372e+18 | 9.223372e+18 | \x5f000000 | t
\x700000f0 | 1.5846086e+29 | 1.5846086e+29 | \x700000f0 | t
\x5f23e9ac | 1.1811161e+19 | 1.1811161e+19 | \x5f23e9ac | t
\x5e9502f9 | 5.368709e+18 | 5.368709e+18 | \x5e9502f9 | t
\x5e8012b1 | 4.6143166e+18 | 4.6143166e+18 | \x5e8012b1 | t
\x3c000028 | 0.007812537 | 0.007812537 | \x3c000028 | t
\x60cde861 | 1.18697725e+20 | 1.18697725e+20 | \x60cde861 | t
\x03aa2a50 | 1.00014165e-36 | 1.00014165e-36 | \x03aa2a50 | t
\x43480000 | 200 | 200 | \x43480000 | t
\x4c000000 | 3.3554432e+07 | 3.3554432e+07 | \x4c000000 | t
\x5d1502f9 | 6.7108864e+17 | 6.7108864e+17 | \x5d1502f9 | t
\x5d9502f9 | 1.3421773e+18 | 1.3421773e+18 | \x5d9502f9 | t
\x5e1502f9 | 2.6843546e+18 | 2.6843546e+18 | \x5e1502f9 | t
\x3f99999a | 1.2 | 1.2 | \x3f99999a | t
\x3f9d70a4 | 1.23 | 1.23 | \x3f9d70a4 | t
\x3f9df3b6 | 1.234 | 1.234 | \x3f9df3b6 | t
\x3f9e0419 | 1.2345 | 1.2345 | \x3f9e0419 | t
\x3f9e0610 | 1.23456 | 1.23456 | \x3f9e0610 | t
\x3f9e064b | 1.234567 | 1.234567 | \x3f9e064b | t
\x3f9e0651 | 1.2345678 | 1.2345678 | \x3f9e0651 | t
\x03d20cfe | 1.23456735e-36 | 1.23456735e-36 | \x03d20cfe | t
(262 rows)
-- clean up, lest opr_sanity complain
\set VERBOSITY terse
drop type xfloat4 cascade;
NOTICE: drop cascades to 6 other objects
\set VERBOSITY default
--

View File

@ -28,6 +28,13 @@ SELECT '-10e-400'::float8;
-0
(1 row)
-- test smallest normalized input
SELECT float8send('2.2250738585072014E-308'::float8);
float8send
--------------------
\x0010000000000000
(1 row)
-- bad input
INSERT INTO FLOAT8_TBL(f1) VALUES ('');
ERROR: invalid input syntax for type double precision: ""
@ -213,7 +220,7 @@ SELECT '' AS three, f.f1, f.f1 / '-10' AS x
WHERE f.f1 > '0.0';
three | f1 | x
-------+----------------------+-----------------------
| 1004.3 | -100.43
| 1004.3 | -100.42999999999999
| 1.2345678901234e+200 | -1.2345678901234e+199
| 1.2345678901234e-200 | -1.2345678901234e-201
(3 rows)
@ -230,9 +237,9 @@ SELECT '' AS three, f.f1, f.f1 - '-10' AS x
SELECT '' AS one, f.f1 ^ '2.0' AS square_f1
FROM FLOAT8_TBL f where f.f1 = '1004.3';
one | square_f1
-----+------------
| 1008618.49
one | square_f1
-----+--------------------
| 1008618.4899999999
(1 row)
-- absolute value
@ -314,6 +321,8 @@ select sign(f1) as sign_f1 from float8_tbl f;
1
(5 rows)
-- avoid bit-exact output here because operations may not be bit-exact.
SET extra_float_digits = 0;
-- square root
SELECT sqrt(float8 '64') AS eight;
eight
@ -449,6 +458,7 @@ SELECT '' AS five, * FROM FLOAT8_TBL;
| -1.2345678901234e-200
(5 rows)
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
@ -528,7 +538,6 @@ SELECT '-9223372036854775808.5'::float8::int8;
SELECT '-9223372036854780000'::float8::int8;
ERROR: bigint out of range
-- test exact cases for trigonometric functions in degrees
SET extra_float_digits = 3;
SELECT x,
sind(x),
sind(x) IN (-1,-0.5,0,0.5,1) AS sind_exact
@ -630,4 +639,432 @@ FROM (SELECT 10*cosd(a), 10*sind(a)
10 | 0 | 0 | t
(5 rows)
RESET extra_float_digits;
--
-- test output (and round-trip safety) of various values.
-- To ensure we're testing what we think we're testing, start with
-- float values specified by bit patterns (as a useful side effect,
-- this means we'll fail on non-IEEE platforms).
create type xfloat8;
create function xfloat8in(cstring) returns xfloat8 immutable strict
language internal as 'int8in';
NOTICE: return type xfloat8 is only a shell
create function xfloat8out(xfloat8) returns cstring immutable strict
language internal as 'int8out';
NOTICE: argument type xfloat8 is only a shell
create type xfloat8 (input = xfloat8in, output = xfloat8out, like = float8);
create cast (xfloat8 as float8) without function;
create cast (float8 as xfloat8) without function;
create cast (xfloat8 as bigint) without function;
create cast (bigint as xfloat8) without function;
-- float8: seeeeeee eeeeeeee eeeeeeee mmmmmmmm mmmmmmmm(x4)
-- we don't care to assume the platform's strtod() handles subnormals
-- correctly; those are "use at your own risk". However we do test
-- subnormal outputs, since those are under our control.
with testdata(bits) as (values
-- small subnormals
(x'0000000000000001'),
(x'0000000000000002'), (x'0000000000000003'),
(x'0000000000001000'), (x'0000000100000000'),
(x'0000010000000000'), (x'0000010100000000'),
(x'0000400000000000'), (x'0000400100000000'),
(x'0000800000000000'), (x'0000800000000001'),
-- these values taken from upstream testsuite
(x'00000000000f4240'),
(x'00000000016e3600'),
(x'0000008cdcdea440'),
-- borderline between subnormal and normal
(x'000ffffffffffff0'), (x'000ffffffffffff1'),
(x'000ffffffffffffe'), (x'000fffffffffffff'))
select float8send(flt) as ibits,
flt
from (select bits::bigint::xfloat8::float8 as flt
from testdata
offset 0) s;
ibits | flt
--------------------+-------------------------
\x0000000000000001 | 5e-324
\x0000000000000002 | 1e-323
\x0000000000000003 | 1.5e-323
\x0000000000001000 | 2.0237e-320
\x0000000100000000 | 2.121995791e-314
\x0000010000000000 | 5.43230922487e-312
\x0000010100000000 | 5.45352918278e-312
\x0000400000000000 | 3.4766779039175e-310
\x0000400100000000 | 3.4768901034966e-310
\x0000800000000000 | 6.953355807835e-310
\x0000800000000001 | 6.95335580783505e-310
\x00000000000f4240 | 4.940656e-318
\x00000000016e3600 | 1.18575755e-316
\x0000008cdcdea440 | 2.989102097996e-312
\x000ffffffffffff0 | 2.2250738585071935e-308
\x000ffffffffffff1 | 2.225073858507194e-308
\x000ffffffffffffe | 2.2250738585072004e-308
\x000fffffffffffff | 2.225073858507201e-308
(18 rows)
-- round-trip tests
with testdata(bits) as (values
(x'0000000000000000'),
-- smallest normal values
(x'0010000000000000'), (x'0010000000000001'),
(x'0010000000000002'), (x'0018000000000000'),
--
(x'3ddb7cdfd9d7bdba'), (x'3ddb7cdfd9d7bdbb'), (x'3ddb7cdfd9d7bdbc'),
(x'3e112e0be826d694'), (x'3e112e0be826d695'), (x'3e112e0be826d696'),
(x'3e45798ee2308c39'), (x'3e45798ee2308c3a'), (x'3e45798ee2308c3b'),
(x'3e7ad7f29abcaf47'), (x'3e7ad7f29abcaf48'), (x'3e7ad7f29abcaf49'),
(x'3eb0c6f7a0b5ed8c'), (x'3eb0c6f7a0b5ed8d'), (x'3eb0c6f7a0b5ed8e'),
(x'3ee4f8b588e368ef'), (x'3ee4f8b588e368f0'), (x'3ee4f8b588e368f1'),
(x'3f1a36e2eb1c432c'), (x'3f1a36e2eb1c432d'), (x'3f1a36e2eb1c432e'),
(x'3f50624dd2f1a9fb'), (x'3f50624dd2f1a9fc'), (x'3f50624dd2f1a9fd'),
(x'3f847ae147ae147a'), (x'3f847ae147ae147b'), (x'3f847ae147ae147c'),
(x'3fb9999999999999'), (x'3fb999999999999a'), (x'3fb999999999999b'),
-- values very close to 1
(x'3feffffffffffff0'), (x'3feffffffffffff1'), (x'3feffffffffffff2'),
(x'3feffffffffffff3'), (x'3feffffffffffff4'), (x'3feffffffffffff5'),
(x'3feffffffffffff6'), (x'3feffffffffffff7'), (x'3feffffffffffff8'),
(x'3feffffffffffff9'), (x'3feffffffffffffa'), (x'3feffffffffffffb'),
(x'3feffffffffffffc'), (x'3feffffffffffffd'), (x'3feffffffffffffe'),
(x'3fefffffffffffff'),
(x'3ff0000000000000'),
(x'3ff0000000000001'), (x'3ff0000000000002'), (x'3ff0000000000003'),
(x'3ff0000000000004'), (x'3ff0000000000005'), (x'3ff0000000000006'),
(x'3ff0000000000007'), (x'3ff0000000000008'), (x'3ff0000000000009'),
--
(x'3ff921fb54442d18'),
(x'4005bf0a8b14576a'),
(x'400921fb54442d18'),
--
(x'4023ffffffffffff'), (x'4024000000000000'), (x'4024000000000001'),
(x'4058ffffffffffff'), (x'4059000000000000'), (x'4059000000000001'),
(x'408f3fffffffffff'), (x'408f400000000000'), (x'408f400000000001'),
(x'40c387ffffffffff'), (x'40c3880000000000'), (x'40c3880000000001'),
(x'40f869ffffffffff'), (x'40f86a0000000000'), (x'40f86a0000000001'),
(x'412e847fffffffff'), (x'412e848000000000'), (x'412e848000000001'),
(x'416312cfffffffff'), (x'416312d000000000'), (x'416312d000000001'),
(x'4197d783ffffffff'), (x'4197d78400000000'), (x'4197d78400000001'),
(x'41cdcd64ffffffff'), (x'41cdcd6500000000'), (x'41cdcd6500000001'),
(x'4202a05f1fffffff'), (x'4202a05f20000000'), (x'4202a05f20000001'),
(x'42374876e7ffffff'), (x'42374876e8000000'), (x'42374876e8000001'),
(x'426d1a94a1ffffff'), (x'426d1a94a2000000'), (x'426d1a94a2000001'),
(x'42a2309ce53fffff'), (x'42a2309ce5400000'), (x'42a2309ce5400001'),
(x'42d6bcc41e8fffff'), (x'42d6bcc41e900000'), (x'42d6bcc41e900001'),
(x'430c6bf52633ffff'), (x'430c6bf526340000'), (x'430c6bf526340001'),
(x'4341c37937e07fff'), (x'4341c37937e08000'), (x'4341c37937e08001'),
(x'4376345785d89fff'), (x'4376345785d8a000'), (x'4376345785d8a001'),
(x'43abc16d674ec7ff'), (x'43abc16d674ec800'), (x'43abc16d674ec801'),
(x'43e158e460913cff'), (x'43e158e460913d00'), (x'43e158e460913d01'),
(x'4415af1d78b58c3f'), (x'4415af1d78b58c40'), (x'4415af1d78b58c41'),
(x'444b1ae4d6e2ef4f'), (x'444b1ae4d6e2ef50'), (x'444b1ae4d6e2ef51'),
(x'4480f0cf064dd591'), (x'4480f0cf064dd592'), (x'4480f0cf064dd593'),
(x'44b52d02c7e14af5'), (x'44b52d02c7e14af6'), (x'44b52d02c7e14af7'),
(x'44ea784379d99db3'), (x'44ea784379d99db4'), (x'44ea784379d99db5'),
(x'45208b2a2c280290'), (x'45208b2a2c280291'), (x'45208b2a2c280292'),
--
(x'7feffffffffffffe'), (x'7fefffffffffffff'),
-- round to even tests (+ve)
(x'4350000000000002'),
(x'4350000000002e06'),
(x'4352000000000003'),
(x'4352000000000004'),
(x'4358000000000003'),
(x'4358000000000004'),
(x'435f000000000020'),
-- round to even tests (-ve)
(x'c350000000000002'),
(x'c350000000002e06'),
(x'c352000000000003'),
(x'c352000000000004'),
(x'c358000000000003'),
(x'c358000000000004'),
(x'c35f000000000020'),
-- exercise fixed-point memmoves
(x'42dc12218377de66'),
(x'42a674e79c5fe51f'),
(x'4271f71fb04cb74c'),
(x'423cbe991a145879'),
(x'4206fee0e1a9e061'),
(x'41d26580b487e6b4'),
(x'419d6f34540ca453'),
(x'41678c29dcd6e9dc'),
(x'4132d687e3df217d'),
(x'40fe240c9fcb68c8'),
(x'40c81cd6e63c53d3'),
(x'40934a4584fd0fdc'),
(x'405edd3c07fb4c93'),
(x'4028b0fcd32f7076'),
(x'3ff3c0ca428c59f8'),
-- these cases come from the upstream's testsuite
-- LotsOfTrailingZeros)
(x'3e60000000000000'),
-- Regression
(x'c352bd2668e077c4'),
(x'434018601510c000'),
(x'43d055dc36f24000'),
(x'43e052961c6f8000'),
(x'3ff3c0ca2a5b1d5d'),
-- LooksLikePow5
(x'4830f0cf064dd592'),
(x'4840f0cf064dd592'),
(x'4850f0cf064dd592'),
-- OutputLength
(x'3ff3333333333333'),
(x'3ff3ae147ae147ae'),
(x'3ff3be76c8b43958'),
(x'3ff3c083126e978d'),
(x'3ff3c0c1fc8f3238'),
(x'3ff3c0c9539b8887'),
(x'3ff3c0ca2a5b1d5d'),
(x'3ff3c0ca4283de1b'),
(x'3ff3c0ca43db770a'),
(x'3ff3c0ca428abd53'),
(x'3ff3c0ca428c1d2b'),
(x'3ff3c0ca428c51f2'),
(x'3ff3c0ca428c58fc'),
(x'3ff3c0ca428c59dd'),
(x'3ff3c0ca428c59f8'),
(x'3ff3c0ca428c59fb'),
-- 32-bit chunking
(x'40112e0be8047a7d'),
(x'40112e0be815a889'),
(x'40112e0be826d695'),
(x'40112e0be83804a1'),
(x'40112e0be84932ad'),
-- MinMaxShift
(x'0040000000000000'),
(x'007fffffffffffff'),
(x'0290000000000000'),
(x'029fffffffffffff'),
(x'4350000000000000'),
(x'435fffffffffffff'),
(x'1330000000000000'),
(x'133fffffffffffff'),
(x'3a6fa7161a4d6e0c')
)
select float8send(flt) as ibits,
flt,
flt::text::float8 as r_flt,
float8send(flt::text::float8) as obits,
float8send(flt::text::float8) = float8send(flt) as correct
from (select bits::bigint::xfloat8::float8 as flt
from testdata
offset 0) s;
ibits | flt | r_flt | obits | correct
--------------------+-------------------------+-------------------------+--------------------+---------
\x0000000000000000 | 0 | 0 | \x0000000000000000 | t
\x0010000000000000 | 2.2250738585072014e-308 | 2.2250738585072014e-308 | \x0010000000000000 | t
\x0010000000000001 | 2.225073858507202e-308 | 2.225073858507202e-308 | \x0010000000000001 | t
\x0010000000000002 | 2.2250738585072024e-308 | 2.2250738585072024e-308 | \x0010000000000002 | t
\x0018000000000000 | 3.337610787760802e-308 | 3.337610787760802e-308 | \x0018000000000000 | t
\x3ddb7cdfd9d7bdba | 9.999999999999999e-11 | 9.999999999999999e-11 | \x3ddb7cdfd9d7bdba | t
\x3ddb7cdfd9d7bdbb | 1e-10 | 1e-10 | \x3ddb7cdfd9d7bdbb | t
\x3ddb7cdfd9d7bdbc | 1.0000000000000002e-10 | 1.0000000000000002e-10 | \x3ddb7cdfd9d7bdbc | t
\x3e112e0be826d694 | 9.999999999999999e-10 | 9.999999999999999e-10 | \x3e112e0be826d694 | t
\x3e112e0be826d695 | 1e-09 | 1e-09 | \x3e112e0be826d695 | t
\x3e112e0be826d696 | 1.0000000000000003e-09 | 1.0000000000000003e-09 | \x3e112e0be826d696 | t
\x3e45798ee2308c39 | 9.999999999999999e-09 | 9.999999999999999e-09 | \x3e45798ee2308c39 | t
\x3e45798ee2308c3a | 1e-08 | 1e-08 | \x3e45798ee2308c3a | t
\x3e45798ee2308c3b | 1.0000000000000002e-08 | 1.0000000000000002e-08 | \x3e45798ee2308c3b | t
\x3e7ad7f29abcaf47 | 9.999999999999998e-08 | 9.999999999999998e-08 | \x3e7ad7f29abcaf47 | t
\x3e7ad7f29abcaf48 | 1e-07 | 1e-07 | \x3e7ad7f29abcaf48 | t
\x3e7ad7f29abcaf49 | 1.0000000000000001e-07 | 1.0000000000000001e-07 | \x3e7ad7f29abcaf49 | t
\x3eb0c6f7a0b5ed8c | 9.999999999999997e-07 | 9.999999999999997e-07 | \x3eb0c6f7a0b5ed8c | t
\x3eb0c6f7a0b5ed8d | 1e-06 | 1e-06 | \x3eb0c6f7a0b5ed8d | t
\x3eb0c6f7a0b5ed8e | 1.0000000000000002e-06 | 1.0000000000000002e-06 | \x3eb0c6f7a0b5ed8e | t
\x3ee4f8b588e368ef | 9.999999999999997e-06 | 9.999999999999997e-06 | \x3ee4f8b588e368ef | t
\x3ee4f8b588e368f0 | 9.999999999999999e-06 | 9.999999999999999e-06 | \x3ee4f8b588e368f0 | t
\x3ee4f8b588e368f1 | 1e-05 | 1e-05 | \x3ee4f8b588e368f1 | t
\x3f1a36e2eb1c432c | 9.999999999999999e-05 | 9.999999999999999e-05 | \x3f1a36e2eb1c432c | t
\x3f1a36e2eb1c432d | 0.0001 | 0.0001 | \x3f1a36e2eb1c432d | t
\x3f1a36e2eb1c432e | 0.00010000000000000002 | 0.00010000000000000002 | \x3f1a36e2eb1c432e | t
\x3f50624dd2f1a9fb | 0.0009999999999999998 | 0.0009999999999999998 | \x3f50624dd2f1a9fb | t
\x3f50624dd2f1a9fc | 0.001 | 0.001 | \x3f50624dd2f1a9fc | t
\x3f50624dd2f1a9fd | 0.0010000000000000002 | 0.0010000000000000002 | \x3f50624dd2f1a9fd | t
\x3f847ae147ae147a | 0.009999999999999998 | 0.009999999999999998 | \x3f847ae147ae147a | t
\x3f847ae147ae147b | 0.01 | 0.01 | \x3f847ae147ae147b | t
\x3f847ae147ae147c | 0.010000000000000002 | 0.010000000000000002 | \x3f847ae147ae147c | t
\x3fb9999999999999 | 0.09999999999999999 | 0.09999999999999999 | \x3fb9999999999999 | t
\x3fb999999999999a | 0.1 | 0.1 | \x3fb999999999999a | t
\x3fb999999999999b | 0.10000000000000002 | 0.10000000000000002 | \x3fb999999999999b | t
\x3feffffffffffff0 | 0.9999999999999982 | 0.9999999999999982 | \x3feffffffffffff0 | t
\x3feffffffffffff1 | 0.9999999999999983 | 0.9999999999999983 | \x3feffffffffffff1 | t
\x3feffffffffffff2 | 0.9999999999999984 | 0.9999999999999984 | \x3feffffffffffff2 | t
\x3feffffffffffff3 | 0.9999999999999986 | 0.9999999999999986 | \x3feffffffffffff3 | t
\x3feffffffffffff4 | 0.9999999999999987 | 0.9999999999999987 | \x3feffffffffffff4 | t
\x3feffffffffffff5 | 0.9999999999999988 | 0.9999999999999988 | \x3feffffffffffff5 | t
\x3feffffffffffff6 | 0.9999999999999989 | 0.9999999999999989 | \x3feffffffffffff6 | t
\x3feffffffffffff7 | 0.999999999999999 | 0.999999999999999 | \x3feffffffffffff7 | t
\x3feffffffffffff8 | 0.9999999999999991 | 0.9999999999999991 | \x3feffffffffffff8 | t
\x3feffffffffffff9 | 0.9999999999999992 | 0.9999999999999992 | \x3feffffffffffff9 | t
\x3feffffffffffffa | 0.9999999999999993 | 0.9999999999999993 | \x3feffffffffffffa | t
\x3feffffffffffffb | 0.9999999999999994 | 0.9999999999999994 | \x3feffffffffffffb | t
\x3feffffffffffffc | 0.9999999999999996 | 0.9999999999999996 | \x3feffffffffffffc | t
\x3feffffffffffffd | 0.9999999999999997 | 0.9999999999999997 | \x3feffffffffffffd | t
\x3feffffffffffffe | 0.9999999999999998 | 0.9999999999999998 | \x3feffffffffffffe | t
\x3fefffffffffffff | 0.9999999999999999 | 0.9999999999999999 | \x3fefffffffffffff | t
\x3ff0000000000000 | 1 | 1 | \x3ff0000000000000 | t
\x3ff0000000000001 | 1.0000000000000002 | 1.0000000000000002 | \x3ff0000000000001 | t
\x3ff0000000000002 | 1.0000000000000004 | 1.0000000000000004 | \x3ff0000000000002 | t
\x3ff0000000000003 | 1.0000000000000007 | 1.0000000000000007 | \x3ff0000000000003 | t
\x3ff0000000000004 | 1.0000000000000009 | 1.0000000000000009 | \x3ff0000000000004 | t
\x3ff0000000000005 | 1.000000000000001 | 1.000000000000001 | \x3ff0000000000005 | t
\x3ff0000000000006 | 1.0000000000000013 | 1.0000000000000013 | \x3ff0000000000006 | t
\x3ff0000000000007 | 1.0000000000000016 | 1.0000000000000016 | \x3ff0000000000007 | t
\x3ff0000000000008 | 1.0000000000000018 | 1.0000000000000018 | \x3ff0000000000008 | t
\x3ff0000000000009 | 1.000000000000002 | 1.000000000000002 | \x3ff0000000000009 | t
\x3ff921fb54442d18 | 1.5707963267948966 | 1.5707963267948966 | \x3ff921fb54442d18 | t
\x4005bf0a8b14576a | 2.7182818284590455 | 2.7182818284590455 | \x4005bf0a8b14576a | t
\x400921fb54442d18 | 3.141592653589793 | 3.141592653589793 | \x400921fb54442d18 | t
\x4023ffffffffffff | 9.999999999999998 | 9.999999999999998 | \x4023ffffffffffff | t
\x4024000000000000 | 10 | 10 | \x4024000000000000 | t
\x4024000000000001 | 10.000000000000002 | 10.000000000000002 | \x4024000000000001 | t
\x4058ffffffffffff | 99.99999999999999 | 99.99999999999999 | \x4058ffffffffffff | t
\x4059000000000000 | 100 | 100 | \x4059000000000000 | t
\x4059000000000001 | 100.00000000000001 | 100.00000000000001 | \x4059000000000001 | t
\x408f3fffffffffff | 999.9999999999999 | 999.9999999999999 | \x408f3fffffffffff | t
\x408f400000000000 | 1000 | 1000 | \x408f400000000000 | t
\x408f400000000001 | 1000.0000000000001 | 1000.0000000000001 | \x408f400000000001 | t
\x40c387ffffffffff | 9999.999999999998 | 9999.999999999998 | \x40c387ffffffffff | t
\x40c3880000000000 | 10000 | 10000 | \x40c3880000000000 | t
\x40c3880000000001 | 10000.000000000002 | 10000.000000000002 | \x40c3880000000001 | t
\x40f869ffffffffff | 99999.99999999999 | 99999.99999999999 | \x40f869ffffffffff | t
\x40f86a0000000000 | 100000 | 100000 | \x40f86a0000000000 | t
\x40f86a0000000001 | 100000.00000000001 | 100000.00000000001 | \x40f86a0000000001 | t
\x412e847fffffffff | 999999.9999999999 | 999999.9999999999 | \x412e847fffffffff | t
\x412e848000000000 | 1000000 | 1000000 | \x412e848000000000 | t
\x412e848000000001 | 1000000.0000000001 | 1000000.0000000001 | \x412e848000000001 | t
\x416312cfffffffff | 9999999.999999998 | 9999999.999999998 | \x416312cfffffffff | t
\x416312d000000000 | 10000000 | 10000000 | \x416312d000000000 | t
\x416312d000000001 | 10000000.000000002 | 10000000.000000002 | \x416312d000000001 | t
\x4197d783ffffffff | 99999999.99999999 | 99999999.99999999 | \x4197d783ffffffff | t
\x4197d78400000000 | 100000000 | 100000000 | \x4197d78400000000 | t
\x4197d78400000001 | 100000000.00000001 | 100000000.00000001 | \x4197d78400000001 | t
\x41cdcd64ffffffff | 999999999.9999999 | 999999999.9999999 | \x41cdcd64ffffffff | t
\x41cdcd6500000000 | 1000000000 | 1000000000 | \x41cdcd6500000000 | t
\x41cdcd6500000001 | 1000000000.0000001 | 1000000000.0000001 | \x41cdcd6500000001 | t
\x4202a05f1fffffff | 9999999999.999998 | 9999999999.999998 | \x4202a05f1fffffff | t
\x4202a05f20000000 | 10000000000 | 10000000000 | \x4202a05f20000000 | t
\x4202a05f20000001 | 10000000000.000002 | 10000000000.000002 | \x4202a05f20000001 | t
\x42374876e7ffffff | 99999999999.99998 | 99999999999.99998 | \x42374876e7ffffff | t
\x42374876e8000000 | 100000000000 | 100000000000 | \x42374876e8000000 | t
\x42374876e8000001 | 100000000000.00002 | 100000000000.00002 | \x42374876e8000001 | t
\x426d1a94a1ffffff | 999999999999.9999 | 999999999999.9999 | \x426d1a94a1ffffff | t
\x426d1a94a2000000 | 1000000000000 | 1000000000000 | \x426d1a94a2000000 | t
\x426d1a94a2000001 | 1000000000000.0001 | 1000000000000.0001 | \x426d1a94a2000001 | t
\x42a2309ce53fffff | 9999999999999.998 | 9999999999999.998 | \x42a2309ce53fffff | t
\x42a2309ce5400000 | 10000000000000 | 10000000000000 | \x42a2309ce5400000 | t
\x42a2309ce5400001 | 10000000000000.002 | 10000000000000.002 | \x42a2309ce5400001 | t
\x42d6bcc41e8fffff | 99999999999999.98 | 99999999999999.98 | \x42d6bcc41e8fffff | t
\x42d6bcc41e900000 | 100000000000000 | 100000000000000 | \x42d6bcc41e900000 | t
\x42d6bcc41e900001 | 100000000000000.02 | 100000000000000.02 | \x42d6bcc41e900001 | t
\x430c6bf52633ffff | 999999999999999.9 | 999999999999999.9 | \x430c6bf52633ffff | t
\x430c6bf526340000 | 1e+15 | 1e+15 | \x430c6bf526340000 | t
\x430c6bf526340001 | 1.0000000000000001e+15 | 1.0000000000000001e+15 | \x430c6bf526340001 | t
\x4341c37937e07fff | 9.999999999999998e+15 | 9.999999999999998e+15 | \x4341c37937e07fff | t
\x4341c37937e08000 | 1e+16 | 1e+16 | \x4341c37937e08000 | t
\x4341c37937e08001 | 1.0000000000000002e+16 | 1.0000000000000002e+16 | \x4341c37937e08001 | t
\x4376345785d89fff | 9.999999999999998e+16 | 9.999999999999998e+16 | \x4376345785d89fff | t
\x4376345785d8a000 | 1e+17 | 1e+17 | \x4376345785d8a000 | t
\x4376345785d8a001 | 1.0000000000000002e+17 | 1.0000000000000002e+17 | \x4376345785d8a001 | t
\x43abc16d674ec7ff | 9.999999999999999e+17 | 9.999999999999999e+17 | \x43abc16d674ec7ff | t
\x43abc16d674ec800 | 1e+18 | 1e+18 | \x43abc16d674ec800 | t
\x43abc16d674ec801 | 1.0000000000000001e+18 | 1.0000000000000001e+18 | \x43abc16d674ec801 | t
\x43e158e460913cff | 9.999999999999998e+18 | 9.999999999999998e+18 | \x43e158e460913cff | t
\x43e158e460913d00 | 1e+19 | 1e+19 | \x43e158e460913d00 | t
\x43e158e460913d01 | 1.0000000000000002e+19 | 1.0000000000000002e+19 | \x43e158e460913d01 | t
\x4415af1d78b58c3f | 9.999999999999998e+19 | 9.999999999999998e+19 | \x4415af1d78b58c3f | t
\x4415af1d78b58c40 | 1e+20 | 1e+20 | \x4415af1d78b58c40 | t
\x4415af1d78b58c41 | 1.0000000000000002e+20 | 1.0000000000000002e+20 | \x4415af1d78b58c41 | t
\x444b1ae4d6e2ef4f | 9.999999999999999e+20 | 9.999999999999999e+20 | \x444b1ae4d6e2ef4f | t
\x444b1ae4d6e2ef50 | 1e+21 | 1e+21 | \x444b1ae4d6e2ef50 | t
\x444b1ae4d6e2ef51 | 1.0000000000000001e+21 | 1.0000000000000001e+21 | \x444b1ae4d6e2ef51 | t
\x4480f0cf064dd591 | 9.999999999999998e+21 | 9.999999999999998e+21 | \x4480f0cf064dd591 | t
\x4480f0cf064dd592 | 1e+22 | 1e+22 | \x4480f0cf064dd592 | t
\x4480f0cf064dd593 | 1.0000000000000002e+22 | 1.0000000000000002e+22 | \x4480f0cf064dd593 | t
\x44b52d02c7e14af5 | 9.999999999999997e+22 | 9.999999999999997e+22 | \x44b52d02c7e14af5 | t
\x44b52d02c7e14af6 | 9.999999999999999e+22 | 9.999999999999999e+22 | \x44b52d02c7e14af6 | t
\x44b52d02c7e14af7 | 1.0000000000000001e+23 | 1.0000000000000001e+23 | \x44b52d02c7e14af7 | t
\x44ea784379d99db3 | 9.999999999999998e+23 | 9.999999999999998e+23 | \x44ea784379d99db3 | t
\x44ea784379d99db4 | 1e+24 | 1e+24 | \x44ea784379d99db4 | t
\x44ea784379d99db5 | 1.0000000000000001e+24 | 1.0000000000000001e+24 | \x44ea784379d99db5 | t
\x45208b2a2c280290 | 9.999999999999999e+24 | 9.999999999999999e+24 | \x45208b2a2c280290 | t
\x45208b2a2c280291 | 1e+25 | 1e+25 | \x45208b2a2c280291 | t
\x45208b2a2c280292 | 1.0000000000000003e+25 | 1.0000000000000003e+25 | \x45208b2a2c280292 | t
\x7feffffffffffffe | 1.7976931348623155e+308 | 1.7976931348623155e+308 | \x7feffffffffffffe | t
\x7fefffffffffffff | 1.7976931348623157e+308 | 1.7976931348623157e+308 | \x7fefffffffffffff | t
\x4350000000000002 | 1.8014398509481992e+16 | 1.8014398509481992e+16 | \x4350000000000002 | t
\x4350000000002e06 | 1.8014398509529112e+16 | 1.8014398509529112e+16 | \x4350000000002e06 | t
\x4352000000000003 | 2.0266198323167244e+16 | 2.0266198323167244e+16 | \x4352000000000003 | t
\x4352000000000004 | 2.0266198323167248e+16 | 2.0266198323167248e+16 | \x4352000000000004 | t
\x4358000000000003 | 2.7021597764222988e+16 | 2.7021597764222988e+16 | \x4358000000000003 | t
\x4358000000000004 | 2.7021597764222992e+16 | 2.7021597764222992e+16 | \x4358000000000004 | t
\x435f000000000020 | 3.4902897112121472e+16 | 3.4902897112121472e+16 | \x435f000000000020 | t
\xc350000000000002 | -1.8014398509481992e+16 | -1.8014398509481992e+16 | \xc350000000000002 | t
\xc350000000002e06 | -1.8014398509529112e+16 | -1.8014398509529112e+16 | \xc350000000002e06 | t
\xc352000000000003 | -2.0266198323167244e+16 | -2.0266198323167244e+16 | \xc352000000000003 | t
\xc352000000000004 | -2.0266198323167248e+16 | -2.0266198323167248e+16 | \xc352000000000004 | t
\xc358000000000003 | -2.7021597764222988e+16 | -2.7021597764222988e+16 | \xc358000000000003 | t
\xc358000000000004 | -2.7021597764222992e+16 | -2.7021597764222992e+16 | \xc358000000000004 | t
\xc35f000000000020 | -3.4902897112121472e+16 | -3.4902897112121472e+16 | \xc35f000000000020 | t
\x42dc12218377de66 | 123456789012345.6 | 123456789012345.6 | \x42dc12218377de66 | t
\x42a674e79c5fe51f | 12345678901234.56 | 12345678901234.56 | \x42a674e79c5fe51f | t
\x4271f71fb04cb74c | 1234567890123.456 | 1234567890123.456 | \x4271f71fb04cb74c | t
\x423cbe991a145879 | 123456789012.3456 | 123456789012.3456 | \x423cbe991a145879 | t
\x4206fee0e1a9e061 | 12345678901.23456 | 12345678901.23456 | \x4206fee0e1a9e061 | t
\x41d26580b487e6b4 | 1234567890.123456 | 1234567890.123456 | \x41d26580b487e6b4 | t
\x419d6f34540ca453 | 123456789.0123456 | 123456789.0123456 | \x419d6f34540ca453 | t
\x41678c29dcd6e9dc | 12345678.90123456 | 12345678.90123456 | \x41678c29dcd6e9dc | t
\x4132d687e3df217d | 1234567.890123456 | 1234567.890123456 | \x4132d687e3df217d | t
\x40fe240c9fcb68c8 | 123456.7890123456 | 123456.7890123456 | \x40fe240c9fcb68c8 | t
\x40c81cd6e63c53d3 | 12345.67890123456 | 12345.67890123456 | \x40c81cd6e63c53d3 | t
\x40934a4584fd0fdc | 1234.567890123456 | 1234.567890123456 | \x40934a4584fd0fdc | t
\x405edd3c07fb4c93 | 123.4567890123456 | 123.4567890123456 | \x405edd3c07fb4c93 | t
\x4028b0fcd32f7076 | 12.34567890123456 | 12.34567890123456 | \x4028b0fcd32f7076 | t
\x3ff3c0ca428c59f8 | 1.234567890123456 | 1.234567890123456 | \x3ff3c0ca428c59f8 | t
\x3e60000000000000 | 2.9802322387695312e-08 | 2.9802322387695312e-08 | \x3e60000000000000 | t
\xc352bd2668e077c4 | -2.1098088986959632e+16 | -2.1098088986959632e+16 | \xc352bd2668e077c4 | t
\x434018601510c000 | 9.0608011534336e+15 | 9.0608011534336e+15 | \x434018601510c000 | t
\x43d055dc36f24000 | 4.708356024711512e+18 | 4.708356024711512e+18 | \x43d055dc36f24000 | t
\x43e052961c6f8000 | 9.409340012568248e+18 | 9.409340012568248e+18 | \x43e052961c6f8000 | t
\x3ff3c0ca2a5b1d5d | 1.2345678 | 1.2345678 | \x3ff3c0ca2a5b1d5d | t
\x4830f0cf064dd592 | 5.764607523034235e+39 | 5.764607523034235e+39 | \x4830f0cf064dd592 | t
\x4840f0cf064dd592 | 1.152921504606847e+40 | 1.152921504606847e+40 | \x4840f0cf064dd592 | t
\x4850f0cf064dd592 | 2.305843009213694e+40 | 2.305843009213694e+40 | \x4850f0cf064dd592 | t
\x3ff3333333333333 | 1.2 | 1.2 | \x3ff3333333333333 | t
\x3ff3ae147ae147ae | 1.23 | 1.23 | \x3ff3ae147ae147ae | t
\x3ff3be76c8b43958 | 1.234 | 1.234 | \x3ff3be76c8b43958 | t
\x3ff3c083126e978d | 1.2345 | 1.2345 | \x3ff3c083126e978d | t
\x3ff3c0c1fc8f3238 | 1.23456 | 1.23456 | \x3ff3c0c1fc8f3238 | t
\x3ff3c0c9539b8887 | 1.234567 | 1.234567 | \x3ff3c0c9539b8887 | t
\x3ff3c0ca2a5b1d5d | 1.2345678 | 1.2345678 | \x3ff3c0ca2a5b1d5d | t
\x3ff3c0ca4283de1b | 1.23456789 | 1.23456789 | \x3ff3c0ca4283de1b | t
\x3ff3c0ca43db770a | 1.234567895 | 1.234567895 | \x3ff3c0ca43db770a | t
\x3ff3c0ca428abd53 | 1.2345678901 | 1.2345678901 | \x3ff3c0ca428abd53 | t
\x3ff3c0ca428c1d2b | 1.23456789012 | 1.23456789012 | \x3ff3c0ca428c1d2b | t
\x3ff3c0ca428c51f2 | 1.234567890123 | 1.234567890123 | \x3ff3c0ca428c51f2 | t
\x3ff3c0ca428c58fc | 1.2345678901234 | 1.2345678901234 | \x3ff3c0ca428c58fc | t
\x3ff3c0ca428c59dd | 1.23456789012345 | 1.23456789012345 | \x3ff3c0ca428c59dd | t
\x3ff3c0ca428c59f8 | 1.234567890123456 | 1.234567890123456 | \x3ff3c0ca428c59f8 | t
\x3ff3c0ca428c59fb | 1.2345678901234567 | 1.2345678901234567 | \x3ff3c0ca428c59fb | t
\x40112e0be8047a7d | 4.294967294 | 4.294967294 | \x40112e0be8047a7d | t
\x40112e0be815a889 | 4.294967295 | 4.294967295 | \x40112e0be815a889 | t
\x40112e0be826d695 | 4.294967296 | 4.294967296 | \x40112e0be826d695 | t
\x40112e0be83804a1 | 4.294967297 | 4.294967297 | \x40112e0be83804a1 | t
\x40112e0be84932ad | 4.294967298 | 4.294967298 | \x40112e0be84932ad | t
\x0040000000000000 | 1.7800590868057611e-307 | 1.7800590868057611e-307 | \x0040000000000000 | t
\x007fffffffffffff | 2.8480945388892175e-306 | 2.8480945388892175e-306 | \x007fffffffffffff | t
\x0290000000000000 | 2.446494580089078e-296 | 2.446494580089078e-296 | \x0290000000000000 | t
\x029fffffffffffff | 4.8929891601781557e-296 | 4.8929891601781557e-296 | \x029fffffffffffff | t
\x4350000000000000 | 1.8014398509481984e+16 | 1.8014398509481984e+16 | \x4350000000000000 | t
\x435fffffffffffff | 3.6028797018963964e+16 | 3.6028797018963964e+16 | \x435fffffffffffff | t
\x1330000000000000 | 2.900835519859558e-216 | 2.900835519859558e-216 | \x1330000000000000 | t
\x133fffffffffffff | 5.801671039719115e-216 | 5.801671039719115e-216 | \x133fffffffffffff | t
\x3a6fa7161a4d6e0c | 3.196104012172126e-27 | 3.196104012172126e-27 | \x3a6fa7161a4d6e0c | t
(209 rows)
-- clean up, lest opr_sanity complain
\set VERBOSITY terse
drop type xfloat8 cascade;
NOTICE: drop cascades to 6 other objects
\set VERBOSITY default
--

View File

@ -24,6 +24,13 @@ SELECT '-10e-400'::float8;
ERROR: "-10e-400" is out of range for type double precision
LINE 1: SELECT '-10e-400'::float8;
^
-- test smallest normalized input
SELECT float8send('2.2250738585072014E-308'::float8);
float8send
--------------------
\x0010000000000000
(1 row)
-- bad input
INSERT INTO FLOAT8_TBL(f1) VALUES ('');
ERROR: invalid input syntax for type double precision: ""
@ -209,7 +216,7 @@ SELECT '' AS three, f.f1, f.f1 / '-10' AS x
WHERE f.f1 > '0.0';
three | f1 | x
-------+----------------------+-----------------------
| 1004.3 | -100.43
| 1004.3 | -100.42999999999999
| 1.2345678901234e+200 | -1.2345678901234e+199
| 1.2345678901234e-200 | -1.2345678901234e-201
(3 rows)
@ -226,9 +233,9 @@ SELECT '' AS three, f.f1, f.f1 - '-10' AS x
SELECT '' AS one, f.f1 ^ '2.0' AS square_f1
FROM FLOAT8_TBL f where f.f1 = '1004.3';
one | square_f1
-----+------------
| 1008618.49
one | square_f1
-----+--------------------
| 1008618.4899999999
(1 row)
-- absolute value
@ -310,6 +317,8 @@ select sign(f1) as sign_f1 from float8_tbl f;
1
(5 rows)
-- avoid bit-exact output here because operations may not be bit-exact.
SET extra_float_digits = 0;
-- square root
SELECT sqrt(float8 '64') AS eight;
eight
@ -445,6 +454,7 @@ SELECT '' AS five, * FROM FLOAT8_TBL;
| -1.2345678901234e-200
(5 rows)
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
@ -530,7 +540,6 @@ SELECT '-9223372036854775808.5'::float8::int8;
SELECT '-9223372036854780000'::float8::int8;
ERROR: bigint out of range
-- test exact cases for trigonometric functions in degrees
SET extra_float_digits = 3;
SELECT x,
sind(x),
sind(x) IN (-1,-0.5,0,0.5,1) AS sind_exact
@ -632,4 +641,432 @@ FROM (SELECT 10*cosd(a), 10*sind(a)
10 | 0 | 0 | t
(5 rows)
RESET extra_float_digits;
--
-- test output (and round-trip safety) of various values.
-- To ensure we're testing what we think we're testing, start with
-- float values specified by bit patterns (as a useful side effect,
-- this means we'll fail on non-IEEE platforms).
create type xfloat8;
create function xfloat8in(cstring) returns xfloat8 immutable strict
language internal as 'int8in';
NOTICE: return type xfloat8 is only a shell
create function xfloat8out(xfloat8) returns cstring immutable strict
language internal as 'int8out';
NOTICE: argument type xfloat8 is only a shell
create type xfloat8 (input = xfloat8in, output = xfloat8out, like = float8);
create cast (xfloat8 as float8) without function;
create cast (float8 as xfloat8) without function;
create cast (xfloat8 as bigint) without function;
create cast (bigint as xfloat8) without function;
-- float8: seeeeeee eeeeeeee eeeeeeee mmmmmmmm mmmmmmmm(x4)
-- we don't care to assume the platform's strtod() handles subnormals
-- correctly; those are "use at your own risk". However we do test
-- subnormal outputs, since those are under our control.
with testdata(bits) as (values
-- small subnormals
(x'0000000000000001'),
(x'0000000000000002'), (x'0000000000000003'),
(x'0000000000001000'), (x'0000000100000000'),
(x'0000010000000000'), (x'0000010100000000'),
(x'0000400000000000'), (x'0000400100000000'),
(x'0000800000000000'), (x'0000800000000001'),
-- these values taken from upstream testsuite
(x'00000000000f4240'),
(x'00000000016e3600'),
(x'0000008cdcdea440'),
-- borderline between subnormal and normal
(x'000ffffffffffff0'), (x'000ffffffffffff1'),
(x'000ffffffffffffe'), (x'000fffffffffffff'))
select float8send(flt) as ibits,
flt
from (select bits::bigint::xfloat8::float8 as flt
from testdata
offset 0) s;
ibits | flt
--------------------+-------------------------
\x0000000000000001 | 5e-324
\x0000000000000002 | 1e-323
\x0000000000000003 | 1.5e-323
\x0000000000001000 | 2.0237e-320
\x0000000100000000 | 2.121995791e-314
\x0000010000000000 | 5.43230922487e-312
\x0000010100000000 | 5.45352918278e-312
\x0000400000000000 | 3.4766779039175e-310
\x0000400100000000 | 3.4768901034966e-310
\x0000800000000000 | 6.953355807835e-310
\x0000800000000001 | 6.95335580783505e-310
\x00000000000f4240 | 4.940656e-318
\x00000000016e3600 | 1.18575755e-316
\x0000008cdcdea440 | 2.989102097996e-312
\x000ffffffffffff0 | 2.2250738585071935e-308
\x000ffffffffffff1 | 2.225073858507194e-308
\x000ffffffffffffe | 2.2250738585072004e-308
\x000fffffffffffff | 2.225073858507201e-308
(18 rows)
-- round-trip tests
with testdata(bits) as (values
(x'0000000000000000'),
-- smallest normal values
(x'0010000000000000'), (x'0010000000000001'),
(x'0010000000000002'), (x'0018000000000000'),
--
(x'3ddb7cdfd9d7bdba'), (x'3ddb7cdfd9d7bdbb'), (x'3ddb7cdfd9d7bdbc'),
(x'3e112e0be826d694'), (x'3e112e0be826d695'), (x'3e112e0be826d696'),
(x'3e45798ee2308c39'), (x'3e45798ee2308c3a'), (x'3e45798ee2308c3b'),
(x'3e7ad7f29abcaf47'), (x'3e7ad7f29abcaf48'), (x'3e7ad7f29abcaf49'),
(x'3eb0c6f7a0b5ed8c'), (x'3eb0c6f7a0b5ed8d'), (x'3eb0c6f7a0b5ed8e'),
(x'3ee4f8b588e368ef'), (x'3ee4f8b588e368f0'), (x'3ee4f8b588e368f1'),
(x'3f1a36e2eb1c432c'), (x'3f1a36e2eb1c432d'), (x'3f1a36e2eb1c432e'),
(x'3f50624dd2f1a9fb'), (x'3f50624dd2f1a9fc'), (x'3f50624dd2f1a9fd'),
(x'3f847ae147ae147a'), (x'3f847ae147ae147b'), (x'3f847ae147ae147c'),
(x'3fb9999999999999'), (x'3fb999999999999a'), (x'3fb999999999999b'),
-- values very close to 1
(x'3feffffffffffff0'), (x'3feffffffffffff1'), (x'3feffffffffffff2'),
(x'3feffffffffffff3'), (x'3feffffffffffff4'), (x'3feffffffffffff5'),
(x'3feffffffffffff6'), (x'3feffffffffffff7'), (x'3feffffffffffff8'),
(x'3feffffffffffff9'), (x'3feffffffffffffa'), (x'3feffffffffffffb'),
(x'3feffffffffffffc'), (x'3feffffffffffffd'), (x'3feffffffffffffe'),
(x'3fefffffffffffff'),
(x'3ff0000000000000'),
(x'3ff0000000000001'), (x'3ff0000000000002'), (x'3ff0000000000003'),
(x'3ff0000000000004'), (x'3ff0000000000005'), (x'3ff0000000000006'),
(x'3ff0000000000007'), (x'3ff0000000000008'), (x'3ff0000000000009'),
--
(x'3ff921fb54442d18'),
(x'4005bf0a8b14576a'),
(x'400921fb54442d18'),
--
(x'4023ffffffffffff'), (x'4024000000000000'), (x'4024000000000001'),
(x'4058ffffffffffff'), (x'4059000000000000'), (x'4059000000000001'),
(x'408f3fffffffffff'), (x'408f400000000000'), (x'408f400000000001'),
(x'40c387ffffffffff'), (x'40c3880000000000'), (x'40c3880000000001'),
(x'40f869ffffffffff'), (x'40f86a0000000000'), (x'40f86a0000000001'),
(x'412e847fffffffff'), (x'412e848000000000'), (x'412e848000000001'),
(x'416312cfffffffff'), (x'416312d000000000'), (x'416312d000000001'),
(x'4197d783ffffffff'), (x'4197d78400000000'), (x'4197d78400000001'),
(x'41cdcd64ffffffff'), (x'41cdcd6500000000'), (x'41cdcd6500000001'),
(x'4202a05f1fffffff'), (x'4202a05f20000000'), (x'4202a05f20000001'),
(x'42374876e7ffffff'), (x'42374876e8000000'), (x'42374876e8000001'),
(x'426d1a94a1ffffff'), (x'426d1a94a2000000'), (x'426d1a94a2000001'),
(x'42a2309ce53fffff'), (x'42a2309ce5400000'), (x'42a2309ce5400001'),
(x'42d6bcc41e8fffff'), (x'42d6bcc41e900000'), (x'42d6bcc41e900001'),
(x'430c6bf52633ffff'), (x'430c6bf526340000'), (x'430c6bf526340001'),
(x'4341c37937e07fff'), (x'4341c37937e08000'), (x'4341c37937e08001'),
(x'4376345785d89fff'), (x'4376345785d8a000'), (x'4376345785d8a001'),
(x'43abc16d674ec7ff'), (x'43abc16d674ec800'), (x'43abc16d674ec801'),
(x'43e158e460913cff'), (x'43e158e460913d00'), (x'43e158e460913d01'),
(x'4415af1d78b58c3f'), (x'4415af1d78b58c40'), (x'4415af1d78b58c41'),
(x'444b1ae4d6e2ef4f'), (x'444b1ae4d6e2ef50'), (x'444b1ae4d6e2ef51'),
(x'4480f0cf064dd591'), (x'4480f0cf064dd592'), (x'4480f0cf064dd593'),
(x'44b52d02c7e14af5'), (x'44b52d02c7e14af6'), (x'44b52d02c7e14af7'),
(x'44ea784379d99db3'), (x'44ea784379d99db4'), (x'44ea784379d99db5'),
(x'45208b2a2c280290'), (x'45208b2a2c280291'), (x'45208b2a2c280292'),
--
(x'7feffffffffffffe'), (x'7fefffffffffffff'),
-- round to even tests (+ve)
(x'4350000000000002'),
(x'4350000000002e06'),
(x'4352000000000003'),
(x'4352000000000004'),
(x'4358000000000003'),
(x'4358000000000004'),
(x'435f000000000020'),
-- round to even tests (-ve)
(x'c350000000000002'),
(x'c350000000002e06'),
(x'c352000000000003'),
(x'c352000000000004'),
(x'c358000000000003'),
(x'c358000000000004'),
(x'c35f000000000020'),
-- exercise fixed-point memmoves
(x'42dc12218377de66'),
(x'42a674e79c5fe51f'),
(x'4271f71fb04cb74c'),
(x'423cbe991a145879'),
(x'4206fee0e1a9e061'),
(x'41d26580b487e6b4'),
(x'419d6f34540ca453'),
(x'41678c29dcd6e9dc'),
(x'4132d687e3df217d'),
(x'40fe240c9fcb68c8'),
(x'40c81cd6e63c53d3'),
(x'40934a4584fd0fdc'),
(x'405edd3c07fb4c93'),
(x'4028b0fcd32f7076'),
(x'3ff3c0ca428c59f8'),
-- these cases come from the upstream's testsuite
-- LotsOfTrailingZeros)
(x'3e60000000000000'),
-- Regression
(x'c352bd2668e077c4'),
(x'434018601510c000'),
(x'43d055dc36f24000'),
(x'43e052961c6f8000'),
(x'3ff3c0ca2a5b1d5d'),
-- LooksLikePow5
(x'4830f0cf064dd592'),
(x'4840f0cf064dd592'),
(x'4850f0cf064dd592'),
-- OutputLength
(x'3ff3333333333333'),
(x'3ff3ae147ae147ae'),
(x'3ff3be76c8b43958'),
(x'3ff3c083126e978d'),
(x'3ff3c0c1fc8f3238'),
(x'3ff3c0c9539b8887'),
(x'3ff3c0ca2a5b1d5d'),
(x'3ff3c0ca4283de1b'),
(x'3ff3c0ca43db770a'),
(x'3ff3c0ca428abd53'),
(x'3ff3c0ca428c1d2b'),
(x'3ff3c0ca428c51f2'),
(x'3ff3c0ca428c58fc'),
(x'3ff3c0ca428c59dd'),
(x'3ff3c0ca428c59f8'),
(x'3ff3c0ca428c59fb'),
-- 32-bit chunking
(x'40112e0be8047a7d'),
(x'40112e0be815a889'),
(x'40112e0be826d695'),
(x'40112e0be83804a1'),
(x'40112e0be84932ad'),
-- MinMaxShift
(x'0040000000000000'),
(x'007fffffffffffff'),
(x'0290000000000000'),
(x'029fffffffffffff'),
(x'4350000000000000'),
(x'435fffffffffffff'),
(x'1330000000000000'),
(x'133fffffffffffff'),
(x'3a6fa7161a4d6e0c')
)
select float8send(flt) as ibits,
flt,
flt::text::float8 as r_flt,
float8send(flt::text::float8) as obits,
float8send(flt::text::float8) = float8send(flt) as correct
from (select bits::bigint::xfloat8::float8 as flt
from testdata
offset 0) s;
ibits | flt | r_flt | obits | correct
--------------------+-------------------------+-------------------------+--------------------+---------
\x0000000000000000 | 0 | 0 | \x0000000000000000 | t
\x0010000000000000 | 2.2250738585072014e-308 | 2.2250738585072014e-308 | \x0010000000000000 | t
\x0010000000000001 | 2.225073858507202e-308 | 2.225073858507202e-308 | \x0010000000000001 | t
\x0010000000000002 | 2.2250738585072024e-308 | 2.2250738585072024e-308 | \x0010000000000002 | t
\x0018000000000000 | 3.337610787760802e-308 | 3.337610787760802e-308 | \x0018000000000000 | t
\x3ddb7cdfd9d7bdba | 9.999999999999999e-11 | 9.999999999999999e-11 | \x3ddb7cdfd9d7bdba | t
\x3ddb7cdfd9d7bdbb | 1e-10 | 1e-10 | \x3ddb7cdfd9d7bdbb | t
\x3ddb7cdfd9d7bdbc | 1.0000000000000002e-10 | 1.0000000000000002e-10 | \x3ddb7cdfd9d7bdbc | t
\x3e112e0be826d694 | 9.999999999999999e-10 | 9.999999999999999e-10 | \x3e112e0be826d694 | t
\x3e112e0be826d695 | 1e-09 | 1e-09 | \x3e112e0be826d695 | t
\x3e112e0be826d696 | 1.0000000000000003e-09 | 1.0000000000000003e-09 | \x3e112e0be826d696 | t
\x3e45798ee2308c39 | 9.999999999999999e-09 | 9.999999999999999e-09 | \x3e45798ee2308c39 | t
\x3e45798ee2308c3a | 1e-08 | 1e-08 | \x3e45798ee2308c3a | t
\x3e45798ee2308c3b | 1.0000000000000002e-08 | 1.0000000000000002e-08 | \x3e45798ee2308c3b | t
\x3e7ad7f29abcaf47 | 9.999999999999998e-08 | 9.999999999999998e-08 | \x3e7ad7f29abcaf47 | t
\x3e7ad7f29abcaf48 | 1e-07 | 1e-07 | \x3e7ad7f29abcaf48 | t
\x3e7ad7f29abcaf49 | 1.0000000000000001e-07 | 1.0000000000000001e-07 | \x3e7ad7f29abcaf49 | t
\x3eb0c6f7a0b5ed8c | 9.999999999999997e-07 | 9.999999999999997e-07 | \x3eb0c6f7a0b5ed8c | t
\x3eb0c6f7a0b5ed8d | 1e-06 | 1e-06 | \x3eb0c6f7a0b5ed8d | t
\x3eb0c6f7a0b5ed8e | 1.0000000000000002e-06 | 1.0000000000000002e-06 | \x3eb0c6f7a0b5ed8e | t
\x3ee4f8b588e368ef | 9.999999999999997e-06 | 9.999999999999997e-06 | \x3ee4f8b588e368ef | t
\x3ee4f8b588e368f0 | 9.999999999999999e-06 | 9.999999999999999e-06 | \x3ee4f8b588e368f0 | t
\x3ee4f8b588e368f1 | 1e-05 | 1e-05 | \x3ee4f8b588e368f1 | t
\x3f1a36e2eb1c432c | 9.999999999999999e-05 | 9.999999999999999e-05 | \x3f1a36e2eb1c432c | t
\x3f1a36e2eb1c432d | 0.0001 | 0.0001 | \x3f1a36e2eb1c432d | t
\x3f1a36e2eb1c432e | 0.00010000000000000002 | 0.00010000000000000002 | \x3f1a36e2eb1c432e | t
\x3f50624dd2f1a9fb | 0.0009999999999999998 | 0.0009999999999999998 | \x3f50624dd2f1a9fb | t
\x3f50624dd2f1a9fc | 0.001 | 0.001 | \x3f50624dd2f1a9fc | t
\x3f50624dd2f1a9fd | 0.0010000000000000002 | 0.0010000000000000002 | \x3f50624dd2f1a9fd | t
\x3f847ae147ae147a | 0.009999999999999998 | 0.009999999999999998 | \x3f847ae147ae147a | t
\x3f847ae147ae147b | 0.01 | 0.01 | \x3f847ae147ae147b | t
\x3f847ae147ae147c | 0.010000000000000002 | 0.010000000000000002 | \x3f847ae147ae147c | t
\x3fb9999999999999 | 0.09999999999999999 | 0.09999999999999999 | \x3fb9999999999999 | t
\x3fb999999999999a | 0.1 | 0.1 | \x3fb999999999999a | t
\x3fb999999999999b | 0.10000000000000002 | 0.10000000000000002 | \x3fb999999999999b | t
\x3feffffffffffff0 | 0.9999999999999982 | 0.9999999999999982 | \x3feffffffffffff0 | t
\x3feffffffffffff1 | 0.9999999999999983 | 0.9999999999999983 | \x3feffffffffffff1 | t
\x3feffffffffffff2 | 0.9999999999999984 | 0.9999999999999984 | \x3feffffffffffff2 | t
\x3feffffffffffff3 | 0.9999999999999986 | 0.9999999999999986 | \x3feffffffffffff3 | t
\x3feffffffffffff4 | 0.9999999999999987 | 0.9999999999999987 | \x3feffffffffffff4 | t
\x3feffffffffffff5 | 0.9999999999999988 | 0.9999999999999988 | \x3feffffffffffff5 | t
\x3feffffffffffff6 | 0.9999999999999989 | 0.9999999999999989 | \x3feffffffffffff6 | t
\x3feffffffffffff7 | 0.999999999999999 | 0.999999999999999 | \x3feffffffffffff7 | t
\x3feffffffffffff8 | 0.9999999999999991 | 0.9999999999999991 | \x3feffffffffffff8 | t
\x3feffffffffffff9 | 0.9999999999999992 | 0.9999999999999992 | \x3feffffffffffff9 | t
\x3feffffffffffffa | 0.9999999999999993 | 0.9999999999999993 | \x3feffffffffffffa | t
\x3feffffffffffffb | 0.9999999999999994 | 0.9999999999999994 | \x3feffffffffffffb | t
\x3feffffffffffffc | 0.9999999999999996 | 0.9999999999999996 | \x3feffffffffffffc | t
\x3feffffffffffffd | 0.9999999999999997 | 0.9999999999999997 | \x3feffffffffffffd | t
\x3feffffffffffffe | 0.9999999999999998 | 0.9999999999999998 | \x3feffffffffffffe | t
\x3fefffffffffffff | 0.9999999999999999 | 0.9999999999999999 | \x3fefffffffffffff | t
\x3ff0000000000000 | 1 | 1 | \x3ff0000000000000 | t
\x3ff0000000000001 | 1.0000000000000002 | 1.0000000000000002 | \x3ff0000000000001 | t
\x3ff0000000000002 | 1.0000000000000004 | 1.0000000000000004 | \x3ff0000000000002 | t
\x3ff0000000000003 | 1.0000000000000007 | 1.0000000000000007 | \x3ff0000000000003 | t
\x3ff0000000000004 | 1.0000000000000009 | 1.0000000000000009 | \x3ff0000000000004 | t
\x3ff0000000000005 | 1.000000000000001 | 1.000000000000001 | \x3ff0000000000005 | t
\x3ff0000000000006 | 1.0000000000000013 | 1.0000000000000013 | \x3ff0000000000006 | t
\x3ff0000000000007 | 1.0000000000000016 | 1.0000000000000016 | \x3ff0000000000007 | t
\x3ff0000000000008 | 1.0000000000000018 | 1.0000000000000018 | \x3ff0000000000008 | t
\x3ff0000000000009 | 1.000000000000002 | 1.000000000000002 | \x3ff0000000000009 | t
\x3ff921fb54442d18 | 1.5707963267948966 | 1.5707963267948966 | \x3ff921fb54442d18 | t
\x4005bf0a8b14576a | 2.7182818284590455 | 2.7182818284590455 | \x4005bf0a8b14576a | t
\x400921fb54442d18 | 3.141592653589793 | 3.141592653589793 | \x400921fb54442d18 | t
\x4023ffffffffffff | 9.999999999999998 | 9.999999999999998 | \x4023ffffffffffff | t
\x4024000000000000 | 10 | 10 | \x4024000000000000 | t
\x4024000000000001 | 10.000000000000002 | 10.000000000000002 | \x4024000000000001 | t
\x4058ffffffffffff | 99.99999999999999 | 99.99999999999999 | \x4058ffffffffffff | t
\x4059000000000000 | 100 | 100 | \x4059000000000000 | t
\x4059000000000001 | 100.00000000000001 | 100.00000000000001 | \x4059000000000001 | t
\x408f3fffffffffff | 999.9999999999999 | 999.9999999999999 | \x408f3fffffffffff | t
\x408f400000000000 | 1000 | 1000 | \x408f400000000000 | t
\x408f400000000001 | 1000.0000000000001 | 1000.0000000000001 | \x408f400000000001 | t
\x40c387ffffffffff | 9999.999999999998 | 9999.999999999998 | \x40c387ffffffffff | t
\x40c3880000000000 | 10000 | 10000 | \x40c3880000000000 | t
\x40c3880000000001 | 10000.000000000002 | 10000.000000000002 | \x40c3880000000001 | t
\x40f869ffffffffff | 99999.99999999999 | 99999.99999999999 | \x40f869ffffffffff | t
\x40f86a0000000000 | 100000 | 100000 | \x40f86a0000000000 | t
\x40f86a0000000001 | 100000.00000000001 | 100000.00000000001 | \x40f86a0000000001 | t
\x412e847fffffffff | 999999.9999999999 | 999999.9999999999 | \x412e847fffffffff | t
\x412e848000000000 | 1000000 | 1000000 | \x412e848000000000 | t
\x412e848000000001 | 1000000.0000000001 | 1000000.0000000001 | \x412e848000000001 | t
\x416312cfffffffff | 9999999.999999998 | 9999999.999999998 | \x416312cfffffffff | t
\x416312d000000000 | 10000000 | 10000000 | \x416312d000000000 | t
\x416312d000000001 | 10000000.000000002 | 10000000.000000002 | \x416312d000000001 | t
\x4197d783ffffffff | 99999999.99999999 | 99999999.99999999 | \x4197d783ffffffff | t
\x4197d78400000000 | 100000000 | 100000000 | \x4197d78400000000 | t
\x4197d78400000001 | 100000000.00000001 | 100000000.00000001 | \x4197d78400000001 | t
\x41cdcd64ffffffff | 999999999.9999999 | 999999999.9999999 | \x41cdcd64ffffffff | t
\x41cdcd6500000000 | 1000000000 | 1000000000 | \x41cdcd6500000000 | t
\x41cdcd6500000001 | 1000000000.0000001 | 1000000000.0000001 | \x41cdcd6500000001 | t
\x4202a05f1fffffff | 9999999999.999998 | 9999999999.999998 | \x4202a05f1fffffff | t
\x4202a05f20000000 | 10000000000 | 10000000000 | \x4202a05f20000000 | t
\x4202a05f20000001 | 10000000000.000002 | 10000000000.000002 | \x4202a05f20000001 | t
\x42374876e7ffffff | 99999999999.99998 | 99999999999.99998 | \x42374876e7ffffff | t
\x42374876e8000000 | 100000000000 | 100000000000 | \x42374876e8000000 | t
\x42374876e8000001 | 100000000000.00002 | 100000000000.00002 | \x42374876e8000001 | t
\x426d1a94a1ffffff | 999999999999.9999 | 999999999999.9999 | \x426d1a94a1ffffff | t
\x426d1a94a2000000 | 1000000000000 | 1000000000000 | \x426d1a94a2000000 | t
\x426d1a94a2000001 | 1000000000000.0001 | 1000000000000.0001 | \x426d1a94a2000001 | t
\x42a2309ce53fffff | 9999999999999.998 | 9999999999999.998 | \x42a2309ce53fffff | t
\x42a2309ce5400000 | 10000000000000 | 10000000000000 | \x42a2309ce5400000 | t
\x42a2309ce5400001 | 10000000000000.002 | 10000000000000.002 | \x42a2309ce5400001 | t
\x42d6bcc41e8fffff | 99999999999999.98 | 99999999999999.98 | \x42d6bcc41e8fffff | t
\x42d6bcc41e900000 | 100000000000000 | 100000000000000 | \x42d6bcc41e900000 | t
\x42d6bcc41e900001 | 100000000000000.02 | 100000000000000.02 | \x42d6bcc41e900001 | t
\x430c6bf52633ffff | 999999999999999.9 | 999999999999999.9 | \x430c6bf52633ffff | t
\x430c6bf526340000 | 1e+15 | 1e+15 | \x430c6bf526340000 | t
\x430c6bf526340001 | 1.0000000000000001e+15 | 1.0000000000000001e+15 | \x430c6bf526340001 | t
\x4341c37937e07fff | 9.999999999999998e+15 | 9.999999999999998e+15 | \x4341c37937e07fff | t
\x4341c37937e08000 | 1e+16 | 1e+16 | \x4341c37937e08000 | t
\x4341c37937e08001 | 1.0000000000000002e+16 | 1.0000000000000002e+16 | \x4341c37937e08001 | t
\x4376345785d89fff | 9.999999999999998e+16 | 9.999999999999998e+16 | \x4376345785d89fff | t
\x4376345785d8a000 | 1e+17 | 1e+17 | \x4376345785d8a000 | t
\x4376345785d8a001 | 1.0000000000000002e+17 | 1.0000000000000002e+17 | \x4376345785d8a001 | t
\x43abc16d674ec7ff | 9.999999999999999e+17 | 9.999999999999999e+17 | \x43abc16d674ec7ff | t
\x43abc16d674ec800 | 1e+18 | 1e+18 | \x43abc16d674ec800 | t
\x43abc16d674ec801 | 1.0000000000000001e+18 | 1.0000000000000001e+18 | \x43abc16d674ec801 | t
\x43e158e460913cff | 9.999999999999998e+18 | 9.999999999999998e+18 | \x43e158e460913cff | t
\x43e158e460913d00 | 1e+19 | 1e+19 | \x43e158e460913d00 | t
\x43e158e460913d01 | 1.0000000000000002e+19 | 1.0000000000000002e+19 | \x43e158e460913d01 | t
\x4415af1d78b58c3f | 9.999999999999998e+19 | 9.999999999999998e+19 | \x4415af1d78b58c3f | t
\x4415af1d78b58c40 | 1e+20 | 1e+20 | \x4415af1d78b58c40 | t
\x4415af1d78b58c41 | 1.0000000000000002e+20 | 1.0000000000000002e+20 | \x4415af1d78b58c41 | t
\x444b1ae4d6e2ef4f | 9.999999999999999e+20 | 9.999999999999999e+20 | \x444b1ae4d6e2ef4f | t
\x444b1ae4d6e2ef50 | 1e+21 | 1e+21 | \x444b1ae4d6e2ef50 | t
\x444b1ae4d6e2ef51 | 1.0000000000000001e+21 | 1.0000000000000001e+21 | \x444b1ae4d6e2ef51 | t
\x4480f0cf064dd591 | 9.999999999999998e+21 | 9.999999999999998e+21 | \x4480f0cf064dd591 | t
\x4480f0cf064dd592 | 1e+22 | 1e+22 | \x4480f0cf064dd592 | t
\x4480f0cf064dd593 | 1.0000000000000002e+22 | 1.0000000000000002e+22 | \x4480f0cf064dd593 | t
\x44b52d02c7e14af5 | 9.999999999999997e+22 | 9.999999999999997e+22 | \x44b52d02c7e14af5 | t
\x44b52d02c7e14af6 | 9.999999999999999e+22 | 9.999999999999999e+22 | \x44b52d02c7e14af6 | t
\x44b52d02c7e14af7 | 1.0000000000000001e+23 | 1.0000000000000001e+23 | \x44b52d02c7e14af7 | t
\x44ea784379d99db3 | 9.999999999999998e+23 | 9.999999999999998e+23 | \x44ea784379d99db3 | t
\x44ea784379d99db4 | 1e+24 | 1e+24 | \x44ea784379d99db4 | t
\x44ea784379d99db5 | 1.0000000000000001e+24 | 1.0000000000000001e+24 | \x44ea784379d99db5 | t
\x45208b2a2c280290 | 9.999999999999999e+24 | 9.999999999999999e+24 | \x45208b2a2c280290 | t
\x45208b2a2c280291 | 1e+25 | 1e+25 | \x45208b2a2c280291 | t
\x45208b2a2c280292 | 1.0000000000000003e+25 | 1.0000000000000003e+25 | \x45208b2a2c280292 | t
\x7feffffffffffffe | 1.7976931348623155e+308 | 1.7976931348623155e+308 | \x7feffffffffffffe | t
\x7fefffffffffffff | 1.7976931348623157e+308 | 1.7976931348623157e+308 | \x7fefffffffffffff | t
\x4350000000000002 | 1.8014398509481992e+16 | 1.8014398509481992e+16 | \x4350000000000002 | t
\x4350000000002e06 | 1.8014398509529112e+16 | 1.8014398509529112e+16 | \x4350000000002e06 | t
\x4352000000000003 | 2.0266198323167244e+16 | 2.0266198323167244e+16 | \x4352000000000003 | t
\x4352000000000004 | 2.0266198323167248e+16 | 2.0266198323167248e+16 | \x4352000000000004 | t
\x4358000000000003 | 2.7021597764222988e+16 | 2.7021597764222988e+16 | \x4358000000000003 | t
\x4358000000000004 | 2.7021597764222992e+16 | 2.7021597764222992e+16 | \x4358000000000004 | t
\x435f000000000020 | 3.4902897112121472e+16 | 3.4902897112121472e+16 | \x435f000000000020 | t
\xc350000000000002 | -1.8014398509481992e+16 | -1.8014398509481992e+16 | \xc350000000000002 | t
\xc350000000002e06 | -1.8014398509529112e+16 | -1.8014398509529112e+16 | \xc350000000002e06 | t
\xc352000000000003 | -2.0266198323167244e+16 | -2.0266198323167244e+16 | \xc352000000000003 | t
\xc352000000000004 | -2.0266198323167248e+16 | -2.0266198323167248e+16 | \xc352000000000004 | t
\xc358000000000003 | -2.7021597764222988e+16 | -2.7021597764222988e+16 | \xc358000000000003 | t
\xc358000000000004 | -2.7021597764222992e+16 | -2.7021597764222992e+16 | \xc358000000000004 | t
\xc35f000000000020 | -3.4902897112121472e+16 | -3.4902897112121472e+16 | \xc35f000000000020 | t
\x42dc12218377de66 | 123456789012345.6 | 123456789012345.6 | \x42dc12218377de66 | t
\x42a674e79c5fe51f | 12345678901234.56 | 12345678901234.56 | \x42a674e79c5fe51f | t
\x4271f71fb04cb74c | 1234567890123.456 | 1234567890123.456 | \x4271f71fb04cb74c | t
\x423cbe991a145879 | 123456789012.3456 | 123456789012.3456 | \x423cbe991a145879 | t
\x4206fee0e1a9e061 | 12345678901.23456 | 12345678901.23456 | \x4206fee0e1a9e061 | t
\x41d26580b487e6b4 | 1234567890.123456 | 1234567890.123456 | \x41d26580b487e6b4 | t
\x419d6f34540ca453 | 123456789.0123456 | 123456789.0123456 | \x419d6f34540ca453 | t
\x41678c29dcd6e9dc | 12345678.90123456 | 12345678.90123456 | \x41678c29dcd6e9dc | t
\x4132d687e3df217d | 1234567.890123456 | 1234567.890123456 | \x4132d687e3df217d | t
\x40fe240c9fcb68c8 | 123456.7890123456 | 123456.7890123456 | \x40fe240c9fcb68c8 | t
\x40c81cd6e63c53d3 | 12345.67890123456 | 12345.67890123456 | \x40c81cd6e63c53d3 | t
\x40934a4584fd0fdc | 1234.567890123456 | 1234.567890123456 | \x40934a4584fd0fdc | t
\x405edd3c07fb4c93 | 123.4567890123456 | 123.4567890123456 | \x405edd3c07fb4c93 | t
\x4028b0fcd32f7076 | 12.34567890123456 | 12.34567890123456 | \x4028b0fcd32f7076 | t
\x3ff3c0ca428c59f8 | 1.234567890123456 | 1.234567890123456 | \x3ff3c0ca428c59f8 | t
\x3e60000000000000 | 2.9802322387695312e-08 | 2.9802322387695312e-08 | \x3e60000000000000 | t
\xc352bd2668e077c4 | -2.1098088986959632e+16 | -2.1098088986959632e+16 | \xc352bd2668e077c4 | t
\x434018601510c000 | 9.0608011534336e+15 | 9.0608011534336e+15 | \x434018601510c000 | t
\x43d055dc36f24000 | 4.708356024711512e+18 | 4.708356024711512e+18 | \x43d055dc36f24000 | t
\x43e052961c6f8000 | 9.409340012568248e+18 | 9.409340012568248e+18 | \x43e052961c6f8000 | t
\x3ff3c0ca2a5b1d5d | 1.2345678 | 1.2345678 | \x3ff3c0ca2a5b1d5d | t
\x4830f0cf064dd592 | 5.764607523034235e+39 | 5.764607523034235e+39 | \x4830f0cf064dd592 | t
\x4840f0cf064dd592 | 1.152921504606847e+40 | 1.152921504606847e+40 | \x4840f0cf064dd592 | t
\x4850f0cf064dd592 | 2.305843009213694e+40 | 2.305843009213694e+40 | \x4850f0cf064dd592 | t
\x3ff3333333333333 | 1.2 | 1.2 | \x3ff3333333333333 | t
\x3ff3ae147ae147ae | 1.23 | 1.23 | \x3ff3ae147ae147ae | t
\x3ff3be76c8b43958 | 1.234 | 1.234 | \x3ff3be76c8b43958 | t
\x3ff3c083126e978d | 1.2345 | 1.2345 | \x3ff3c083126e978d | t
\x3ff3c0c1fc8f3238 | 1.23456 | 1.23456 | \x3ff3c0c1fc8f3238 | t
\x3ff3c0c9539b8887 | 1.234567 | 1.234567 | \x3ff3c0c9539b8887 | t
\x3ff3c0ca2a5b1d5d | 1.2345678 | 1.2345678 | \x3ff3c0ca2a5b1d5d | t
\x3ff3c0ca4283de1b | 1.23456789 | 1.23456789 | \x3ff3c0ca4283de1b | t
\x3ff3c0ca43db770a | 1.234567895 | 1.234567895 | \x3ff3c0ca43db770a | t
\x3ff3c0ca428abd53 | 1.2345678901 | 1.2345678901 | \x3ff3c0ca428abd53 | t
\x3ff3c0ca428c1d2b | 1.23456789012 | 1.23456789012 | \x3ff3c0ca428c1d2b | t
\x3ff3c0ca428c51f2 | 1.234567890123 | 1.234567890123 | \x3ff3c0ca428c51f2 | t
\x3ff3c0ca428c58fc | 1.2345678901234 | 1.2345678901234 | \x3ff3c0ca428c58fc | t
\x3ff3c0ca428c59dd | 1.23456789012345 | 1.23456789012345 | \x3ff3c0ca428c59dd | t
\x3ff3c0ca428c59f8 | 1.234567890123456 | 1.234567890123456 | \x3ff3c0ca428c59f8 | t
\x3ff3c0ca428c59fb | 1.2345678901234567 | 1.2345678901234567 | \x3ff3c0ca428c59fb | t
\x40112e0be8047a7d | 4.294967294 | 4.294967294 | \x40112e0be8047a7d | t
\x40112e0be815a889 | 4.294967295 | 4.294967295 | \x40112e0be815a889 | t
\x40112e0be826d695 | 4.294967296 | 4.294967296 | \x40112e0be826d695 | t
\x40112e0be83804a1 | 4.294967297 | 4.294967297 | \x40112e0be83804a1 | t
\x40112e0be84932ad | 4.294967298 | 4.294967298 | \x40112e0be84932ad | t
\x0040000000000000 | 1.7800590868057611e-307 | 1.7800590868057611e-307 | \x0040000000000000 | t
\x007fffffffffffff | 2.8480945388892175e-306 | 2.8480945388892175e-306 | \x007fffffffffffff | t
\x0290000000000000 | 2.446494580089078e-296 | 2.446494580089078e-296 | \x0290000000000000 | t
\x029fffffffffffff | 4.8929891601781557e-296 | 4.8929891601781557e-296 | \x029fffffffffffff | t
\x4350000000000000 | 1.8014398509481984e+16 | 1.8014398509481984e+16 | \x4350000000000000 | t
\x435fffffffffffff | 3.6028797018963964e+16 | 3.6028797018963964e+16 | \x435fffffffffffff | t
\x1330000000000000 | 2.900835519859558e-216 | 2.900835519859558e-216 | \x1330000000000000 | t
\x133fffffffffffff | 5.801671039719115e-216 | 5.801671039719115e-216 | \x133fffffffffffff | t
\x3a6fa7161a4d6e0c | 3.196104012172126e-27 | 3.196104012172126e-27 | \x3a6fa7161a4d6e0c | t
(209 rows)
-- clean up, lest opr_sanity complain
\set VERBOSITY terse
drop type xfloat8 cascade;
NOTICE: drop cascades to 6 other objects
\set VERBOSITY default
--

View File

@ -329,23 +329,23 @@ SELECT '' AS five, q1, q2, q1 / q2 AS divide, q1 % q2 AS mod FROM INT8_TBL;
(5 rows)
SELECT '' AS five, q1, float8(q1) FROM INT8_TBL;
five | q1 | float8
------+------------------+----------------------
| 123 | 123
| 123 | 123
| 4567890123456789 | 4.56789012345679e+15
| 4567890123456789 | 4.56789012345679e+15
| 4567890123456789 | 4.56789012345679e+15
five | q1 | float8
------+------------------+-----------------------
| 123 | 123
| 123 | 123
| 4567890123456789 | 4.567890123456789e+15
| 4567890123456789 | 4.567890123456789e+15
| 4567890123456789 | 4.567890123456789e+15
(5 rows)
SELECT '' AS five, q2, float8(q2) FROM INT8_TBL;
five | q2 | float8
------+-------------------+-----------------------
| 456 | 456
| 4567890123456789 | 4.56789012345679e+15
| 123 | 123
| 4567890123456789 | 4.56789012345679e+15
| -4567890123456789 | -4.56789012345679e+15
five | q2 | float8
------+-------------------+------------------------
| 456 | 456
| 4567890123456789 | 4.567890123456789e+15
| 123 | 123
| 4567890123456789 | 4.567890123456789e+15
| -4567890123456789 | -4.567890123456789e+15
(5 rows)
SELECT 37 + q1 AS plus4 FROM INT8_TBL;
@ -726,13 +726,13 @@ SELECT CAST('42'::int2 AS int8), CAST('-37'::int2 AS int8);
(1 row)
SELECT CAST(q1 AS float4), CAST(q2 AS float8) FROM INT8_TBL;
q1 | q2
-------------+-----------------------
123 | 456
123 | 4.56789012345679e+15
4.56789e+15 | 123
4.56789e+15 | 4.56789012345679e+15
4.56789e+15 | -4.56789012345679e+15
q1 | q2
-------------+------------------------
123 | 456
123 | 4.567890123456789e+15
4.56789e+15 | 123
4.56789e+15 | 4.567890123456789e+15
4.56789e+15 | -4.567890123456789e+15
(5 rows)
SELECT CAST('36854775807.0'::float4 AS int8);

View File

@ -4376,9 +4376,9 @@ select '12345.05'::jsonb::numeric;
(1 row)
select '12345.05'::jsonb::float4;
float4
--------
12345
float4
----------
12345.05
(1 row)
select '12345.05'::jsonb::float8;

View File

@ -64,14 +64,14 @@ LINE 1: INSERT INTO LINE_TBL VALUES ('[(1,2),(1,2)]');
INSERT INTO LINE_TBL VALUES (line(point '(1,0)', point '(1,0)'));
ERROR: invalid line specification: must be two distinct points
select * from LINE_TBL;
s
---------------------------------------------
s
------------------------------------------------
{0,-1,5}
{1,0,5}
{0,3,0}
{1,-1,0}
{-0.4,-1,-6}
{-0.000184615384615385,-1,15.3846153846154}
{-0.0001846153846153846,-1,15.384615384615387}
{3,NaN,5}
{NaN,NaN,NaN}
{0,-1,3}

View File

@ -1,6 +1,8 @@
--
-- POINT
--
-- avoid bit-exact output here because operations may not be bit-exact.
SET extra_float_digits = 0;
CREATE TABLE POINT_TBL(f1 point);
INSERT INTO POINT_TBL(f1) VALUES ('(0.0,0.0)');
INSERT INTO POINT_TBL(f1) VALUES ('(-10.0,0.0)');

View File

@ -910,24 +910,24 @@ insert into rtest_comp values ('p4', 'cm', 15.0);
insert into rtest_comp values ('p5', 'inch', 7.0);
insert into rtest_comp values ('p6', 'inch', 4.4);
select * from rtest_vcomp order by part;
part | size_in_cm
------+------------
p1 | 500
p2 | 300
p3 | 5
p4 | 15
p5 | 17.78
p6 | 11.176
part | size_in_cm
------+--------------------
p1 | 500
p2 | 300
p3 | 5
p4 | 15
p5 | 17.78
p6 | 11.176000000000002
(6 rows)
select * from rtest_vcomp where size_in_cm > 10.0 order by size_in_cm using >;
part | size_in_cm
------+------------
p1 | 500
p2 | 300
p5 | 17.78
p4 | 15
p6 | 11.176
part | size_in_cm
------+--------------------
p1 | 500
p2 | 300
p5 | 17.78
p4 | 15
p6 | 11.176000000000002
(5 rows)
--

View File

@ -970,9 +970,9 @@ Water, water, every where,
Nor any drop to drink.
S. T. Coleridge (1772-1834)
'), to_tsquery('english', 'breath&motion&water'));
ts_rank_cd
------------
0.00833333
ts_rank_cd
-------------
0.008333334
(1 row)
SELECT ts_rank_cd(to_tsvector('english', '

View File

@ -787,57 +787,57 @@ select to_tsvector('simple', '') @@ '!foo' AS "true";
--ranking
SELECT ts_rank(' a:1 s:2C d g'::tsvector, 'a | s');
ts_rank
-----------
0.0911891
ts_rank
-------------
0.091189064
(1 row)
SELECT ts_rank(' a:1 sa:2C d g'::tsvector, 'a | s');
ts_rank
-----------
0.0303964
ts_rank
-------------
0.030396355
(1 row)
SELECT ts_rank(' a:1 sa:2C d g'::tsvector, 'a | s:*');
ts_rank
-----------
0.0911891
ts_rank
-------------
0.091189064
(1 row)
SELECT ts_rank(' a:1 sa:2C d g'::tsvector, 'a | sa:*');
ts_rank
-----------
0.0911891
ts_rank
-------------
0.091189064
(1 row)
SELECT ts_rank(' a:1 s:2B d g'::tsvector, 'a | s');
ts_rank
----------
0.151982
ts_rank
------------
0.15198177
(1 row)
SELECT ts_rank(' a:1 s:2 d g'::tsvector, 'a | s');
ts_rank
-----------
0.0607927
ts_rank
------------
0.06079271
(1 row)
SELECT ts_rank(' a:1 s:2C d g'::tsvector, 'a & s');
ts_rank
----------
0.140153
ts_rank
------------
0.14015312
(1 row)
SELECT ts_rank(' a:1 s:2B d g'::tsvector, 'a & s');
ts_rank
----------
0.198206
ts_rank
------------
0.19820644
(1 row)
SELECT ts_rank(' a:1 s:2 d g'::tsvector, 'a & s');
ts_rank
-----------
0.0991032
ts_rank
------------
0.09910322
(1 row)
SELECT ts_rank_cd(' a:1 s:2C d g'::tsvector, 'a | s');
@ -885,7 +885,7 @@ SELECT ts_rank_cd(' a:1 s:2 d g'::tsvector, 'a | s');
SELECT ts_rank_cd(' a:1 s:2C d g'::tsvector, 'a & s');
ts_rank_cd
------------
0.133333
0.13333334
(1 row)
SELECT ts_rank_cd(' a:1 s:2B d g'::tsvector, 'a & s');
@ -903,13 +903,13 @@ SELECT ts_rank_cd(' a:1 s:2 d g'::tsvector, 'a & s');
SELECT ts_rank_cd(' a:1 s:2A d g'::tsvector, 'a <-> s');
ts_rank_cd
------------
0.181818
0.18181819
(1 row)
SELECT ts_rank_cd(' a:1 s:2C d g'::tsvector, 'a <-> s');
ts_rank_cd
------------
0.133333
0.13333334
(1 row)
SELECT ts_rank_cd(' a:1 s:2 d g'::tsvector, 'a <-> s');
@ -927,13 +927,13 @@ SELECT ts_rank_cd(' a:1 s:2 d:2A g'::tsvector, 'a <-> s');
SELECT ts_rank_cd(' a:1 s:2,3A d:2A g'::tsvector, 'a <2> s:A');
ts_rank_cd
------------
0.0909091
0.09090909
(1 row)
SELECT ts_rank_cd(' a:1 b:2 s:3A d:2A g'::tsvector, 'a <2> s:A');
ts_rank_cd
------------
0.0909091
0.09090909
(1 row)
SELECT ts_rank_cd(' a:1 sa:2D sb:2A g'::tsvector, 'a <-> s:*');

View File

@ -1,6 +1,8 @@
--
-- UPDATABLE VIEWS
--
-- avoid bit-exact output here because operations may not be bit-exact.
SET extra_float_digits = 0;
-- check that non-updatable views and columns are rejected with useful error
-- messages
CREATE TABLE base_tbl (a int PRIMARY KEY, b text DEFAULT 'Unspecified');

View File

@ -204,33 +204,33 @@ SELECT dense_rank() OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1
(10 rows)
SELECT percent_rank() OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10;
percent_rank | ten | four
-------------------+-----+------
0 | 0 | 0
0 | 0 | 0
1 | 4 | 0
0 | 1 | 1
0 | 1 | 1
0.666666666666667 | 7 | 1
1 | 9 | 1
0 | 0 | 2
0 | 1 | 3
1 | 3 | 3
percent_rank | ten | four
--------------------+-----+------
0 | 0 | 0
0 | 0 | 0
1 | 4 | 0
0 | 1 | 1
0 | 1 | 1
0.6666666666666666 | 7 | 1
1 | 9 | 1
0 | 0 | 2
0 | 1 | 3
1 | 3 | 3
(10 rows)
SELECT cume_dist() OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10;
cume_dist | ten | four
-------------------+-----+------
0.666666666666667 | 0 | 0
0.666666666666667 | 0 | 0
1 | 4 | 0
0.5 | 1 | 1
0.5 | 1 | 1
0.75 | 7 | 1
1 | 9 | 1
1 | 0 | 2
0.5 | 1 | 3
1 | 3 | 3
cume_dist | ten | four
--------------------+-----+------
0.6666666666666666 | 0 | 0
0.6666666666666666 | 0 | 0
1 | 4 | 0
0.5 | 1 | 1
0.5 | 1 | 1
0.75 | 7 | 1
1 | 9 | 1
1 | 0 | 2
0.5 | 1 | 3
1 | 3 | 3
(10 rows)
SELECT ntile(3) OVER (ORDER BY ten, four), ten, four FROM tenk1 WHERE unique2 < 10;

View File

@ -2,6 +2,9 @@
-- AGGREGATES
--
-- avoid bit-exact output here because operations may not be bit-exact.
SET extra_float_digits = 0;
SELECT avg(four) AS avg_1 FROM onek;
SELECT avg(a) AS avg_32 FROM aggtest WHERE a < 100;

View File

@ -2,6 +2,9 @@
-- CIRCLE
--
-- avoid bit-exact output here because operations may not be bit-exact.
SET extra_float_digits = 0;
CREATE TABLE CIRCLE_TBL (f1 circle);
INSERT INTO CIRCLE_TBL VALUES ('<(5,1),3>');

View File

@ -132,3 +132,222 @@ SELECT float4send('750486563e-38'::float4);
SELECT float4send('1.17549435e-38'::float4);
SELECT float4send('1.1754944e-38'::float4);
-- test output (and round-trip safety) of various values.
-- To ensure we're testing what we think we're testing, start with
-- float values specified by bit patterns (as a useful side effect,
-- this means we'll fail on non-IEEE platforms).
create type xfloat4;
create function xfloat4in(cstring) returns xfloat4 immutable strict
language internal as 'int4in';
create function xfloat4out(xfloat4) returns cstring immutable strict
language internal as 'int4out';
create type xfloat4 (input = xfloat4in, output = xfloat4out, like = float4);
create cast (xfloat4 as float4) without function;
create cast (float4 as xfloat4) without function;
create cast (xfloat4 as integer) without function;
create cast (integer as xfloat4) without function;
-- float4: seeeeeee emmmmmmm mmmmmmmm mmmmmmmm
-- we don't care to assume the platform's strtod() handles subnormals
-- correctly; those are "use at your own risk". However we do test
-- subnormal outputs, since those are under our control.
with testdata(bits) as (values
-- small subnormals
(x'00000001'),
(x'00000002'), (x'00000003'),
(x'00000010'), (x'00000011'), (x'00000100'), (x'00000101'),
(x'00004000'), (x'00004001'), (x'00080000'), (x'00080001'),
-- stress values
(x'0053c4f4'), -- 7693e-42
(x'006c85c4'), -- 996622e-44
(x'0041ca76'), -- 60419369e-46
(x'004b7678'), -- 6930161142e-48
-- taken from upstream testsuite
(x'00000007'),
(x'00424fe2'),
-- borderline between subnormal and normal
(x'007ffff0'), (x'007ffff1'), (x'007ffffe'), (x'007fffff'))
select float4send(flt) as ibits,
flt
from (select bits::integer::xfloat4::float4 as flt
from testdata
offset 0) s;
with testdata(bits) as (values
(x'00000000'),
-- smallest normal values
(x'00800000'), (x'00800001'), (x'00800004'), (x'00800005'),
(x'00800006'),
-- small normal values chosen for short vs. long output
(x'008002f1'), (x'008002f2'), (x'008002f3'),
(x'00800e17'), (x'00800e18'), (x'00800e19'),
-- assorted values (random mantissae)
(x'01000001'), (x'01102843'), (x'01a52c98'),
(x'0219c229'), (x'02e4464d'), (x'037343c1'), (x'03a91b36'),
(x'047ada65'), (x'0496fe87'), (x'0550844f'), (x'05999da3'),
(x'060ea5e2'), (x'06e63c45'), (x'07f1e548'), (x'0fc5282b'),
(x'1f850283'), (x'2874a9d6'),
-- values around 5e-08
(x'3356bf94'), (x'3356bf95'), (x'3356bf96'),
-- around 1e-07
(x'33d6bf94'), (x'33d6bf95'), (x'33d6bf96'),
-- around 3e-07 .. 1e-04
(x'34a10faf'), (x'34a10fb0'), (x'34a10fb1'),
(x'350637bc'), (x'350637bd'), (x'350637be'),
(x'35719786'), (x'35719787'), (x'35719788'),
(x'358637bc'), (x'358637bd'), (x'358637be'),
(x'36a7c5ab'), (x'36a7c5ac'), (x'36a7c5ad'),
(x'3727c5ab'), (x'3727c5ac'), (x'3727c5ad'),
-- format crossover at 1e-04
(x'38d1b714'), (x'38d1b715'), (x'38d1b716'),
(x'38d1b717'), (x'38d1b718'), (x'38d1b719'),
(x'38d1b71a'), (x'38d1b71b'), (x'38d1b71c'),
(x'38d1b71d'),
--
(x'38dffffe'), (x'38dfffff'), (x'38e00000'),
(x'38efffff'), (x'38f00000'), (x'38f00001'),
(x'3a83126e'), (x'3a83126f'), (x'3a831270'),
(x'3c23d709'), (x'3c23d70a'), (x'3c23d70b'),
(x'3dcccccc'), (x'3dcccccd'), (x'3dccccce'),
-- chosen to need 9 digits for 3dcccd70
(x'3dcccd6f'), (x'3dcccd70'), (x'3dcccd71'),
--
(x'3effffff'), (x'3f000000'), (x'3f000001'),
(x'3f333332'), (x'3f333333'), (x'3f333334'),
-- approach 1.0 with increasing numbers of 9s
(x'3f666665'), (x'3f666666'), (x'3f666667'),
(x'3f7d70a3'), (x'3f7d70a4'), (x'3f7d70a5'),
(x'3f7fbe76'), (x'3f7fbe77'), (x'3f7fbe78'),
(x'3f7ff971'), (x'3f7ff972'), (x'3f7ff973'),
(x'3f7fff57'), (x'3f7fff58'), (x'3f7fff59'),
(x'3f7fffee'), (x'3f7fffef'),
-- values very close to 1
(x'3f7ffff0'), (x'3f7ffff1'), (x'3f7ffff2'),
(x'3f7ffff3'), (x'3f7ffff4'), (x'3f7ffff5'),
(x'3f7ffff6'), (x'3f7ffff7'), (x'3f7ffff8'),
(x'3f7ffff9'), (x'3f7ffffa'), (x'3f7ffffb'),
(x'3f7ffffc'), (x'3f7ffffd'), (x'3f7ffffe'),
(x'3f7fffff'),
(x'3f800000'),
(x'3f800001'), (x'3f800002'), (x'3f800003'),
(x'3f800004'), (x'3f800005'), (x'3f800006'),
(x'3f800007'), (x'3f800008'), (x'3f800009'),
-- values 1 to 1.1
(x'3f80000f'), (x'3f800010'), (x'3f800011'),
(x'3f800012'), (x'3f800013'), (x'3f800014'),
(x'3f800017'), (x'3f800018'), (x'3f800019'),
(x'3f80001a'), (x'3f80001b'), (x'3f80001c'),
(x'3f800029'), (x'3f80002a'), (x'3f80002b'),
(x'3f800053'), (x'3f800054'), (x'3f800055'),
(x'3f800346'), (x'3f800347'), (x'3f800348'),
(x'3f8020c4'), (x'3f8020c5'), (x'3f8020c6'),
(x'3f8147ad'), (x'3f8147ae'), (x'3f8147af'),
(x'3f8ccccc'), (x'3f8ccccd'), (x'3f8cccce'),
--
(x'3fc90fdb'), -- pi/2
(x'402df854'), -- e
(x'40490fdb'), -- pi
--
(x'409fffff'), (x'40a00000'), (x'40a00001'),
(x'40afffff'), (x'40b00000'), (x'40b00001'),
(x'411fffff'), (x'41200000'), (x'41200001'),
(x'42c7ffff'), (x'42c80000'), (x'42c80001'),
(x'4479ffff'), (x'447a0000'), (x'447a0001'),
(x'461c3fff'), (x'461c4000'), (x'461c4001'),
(x'47c34fff'), (x'47c35000'), (x'47c35001'),
(x'497423ff'), (x'49742400'), (x'49742401'),
(x'4b18967f'), (x'4b189680'), (x'4b189681'),
(x'4cbebc1f'), (x'4cbebc20'), (x'4cbebc21'),
(x'4e6e6b27'), (x'4e6e6b28'), (x'4e6e6b29'),
(x'501502f8'), (x'501502f9'), (x'501502fa'),
(x'51ba43b6'), (x'51ba43b7'), (x'51ba43b8'),
-- stress values
(x'1f6c1e4a'), -- 5e-20
(x'59be6cea'), -- 67e14
(x'5d5ab6c4'), -- 985e15
(x'2cc4a9bd'), -- 55895e-16
(x'15ae43fd'), -- 7038531e-32
(x'2cf757ca'), -- 702990899e-20
(x'665ba998'), -- 25933168707e13
(x'743c3324'), -- 596428896559e20
-- exercise fixed-point memmoves
(x'47f1205a'),
(x'4640e6ae'),
(x'449a5225'),
(x'42f6e9d5'),
(x'414587dd'),
(x'3f9e064b'),
-- these cases come from the upstream's testsuite
-- BoundaryRoundEven
(x'4c000004'),
(x'50061c46'),
(x'510006a8'),
-- ExactValueRoundEven
(x'48951f84'),
(x'45fd1840'),
-- LotsOfTrailingZeros
(x'39800000'),
(x'3b200000'),
(x'3b900000'),
(x'3bd00000'),
-- Regression
(x'63800000'),
(x'4b000000'),
(x'4b800000'),
(x'4c000001'),
(x'4c800b0d'),
(x'00d24584'),
(x'800000b0'),
(x'00d90b88'),
(x'45803f34'),
(x'4f9f24f7'),
(x'3a8722c3'),
(x'5c800041'),
(x'15ae43fd'),
(x'5d4cccfb'),
(x'4c800001'),
(x'57800ed8'),
(x'5f000000'),
(x'700000f0'),
(x'5f23e9ac'),
(x'5e9502f9'),
(x'5e8012b1'),
(x'3c000028'),
(x'60cde861'),
(x'03aa2a50'),
(x'43480000'),
(x'4c000000'),
-- LooksLikePow5
(x'5D1502F9'),
(x'5D9502F9'),
(x'5E1502F9'),
-- OutputLength
(x'3f99999a'),
(x'3f9d70a4'),
(x'3f9df3b6'),
(x'3f9e0419'),
(x'3f9e0610'),
(x'3f9e064b'),
(x'3f9e0651'),
(x'03d20cfe')
)
select float4send(flt) as ibits,
flt,
flt::text::float4 as r_flt,
float4send(flt::text::float4) as obits,
float4send(flt::text::float4) = float4send(flt) as correct
from (select bits::integer::xfloat4::float4 as flt
from testdata
offset 0) s;
-- clean up, lest opr_sanity complain
\set VERBOSITY terse
drop type xfloat4 cascade;
\set VERBOSITY default
--

View File

@ -16,6 +16,9 @@ SELECT '-10e400'::float8;
SELECT '10e-400'::float8;
SELECT '-10e-400'::float8;
-- test smallest normalized input
SELECT float8send('2.2250738585072014E-308'::float8);
-- bad input
INSERT INTO FLOAT8_TBL(f1) VALUES ('');
INSERT INTO FLOAT8_TBL(f1) VALUES (' ');
@ -97,6 +100,9 @@ select floor(f1) as floor_f1 from float8_tbl f;
-- sign
select sign(f1) as sign_f1 from float8_tbl f;
-- avoid bit-exact output here because operations may not be bit-exact.
SET extra_float_digits = 0;
-- square root
SELECT sqrt(float8 '64') AS eight;
@ -148,6 +154,8 @@ SELECT '' AS bad, f.f1 / '0.0' from FLOAT8_TBL f;
SELECT '' AS five, * FROM FLOAT8_TBL;
RESET extra_float_digits;
-- test for over- and underflow
INSERT INTO FLOAT8_TBL(f1) VALUES ('10e400');
@ -189,7 +197,6 @@ SELECT '-9223372036854775808.5'::float8::int8;
SELECT '-9223372036854780000'::float8::int8;
-- test exact cases for trigonometric functions in degrees
SET extra_float_digits = 3;
SELECT x,
sind(x),
@ -232,4 +239,203 @@ SELECT x, y,
FROM (SELECT 10*cosd(a), 10*sind(a)
FROM generate_series(0, 360, 90) AS t(a)) AS t(x,y);
RESET extra_float_digits;
--
-- test output (and round-trip safety) of various values.
-- To ensure we're testing what we think we're testing, start with
-- float values specified by bit patterns (as a useful side effect,
-- this means we'll fail on non-IEEE platforms).
create type xfloat8;
create function xfloat8in(cstring) returns xfloat8 immutable strict
language internal as 'int8in';
create function xfloat8out(xfloat8) returns cstring immutable strict
language internal as 'int8out';
create type xfloat8 (input = xfloat8in, output = xfloat8out, like = float8);
create cast (xfloat8 as float8) without function;
create cast (float8 as xfloat8) without function;
create cast (xfloat8 as bigint) without function;
create cast (bigint as xfloat8) without function;
-- float8: seeeeeee eeeeeeee eeeeeeee mmmmmmmm mmmmmmmm(x4)
-- we don't care to assume the platform's strtod() handles subnormals
-- correctly; those are "use at your own risk". However we do test
-- subnormal outputs, since those are under our control.
with testdata(bits) as (values
-- small subnormals
(x'0000000000000001'),
(x'0000000000000002'), (x'0000000000000003'),
(x'0000000000001000'), (x'0000000100000000'),
(x'0000010000000000'), (x'0000010100000000'),
(x'0000400000000000'), (x'0000400100000000'),
(x'0000800000000000'), (x'0000800000000001'),
-- these values taken from upstream testsuite
(x'00000000000f4240'),
(x'00000000016e3600'),
(x'0000008cdcdea440'),
-- borderline between subnormal and normal
(x'000ffffffffffff0'), (x'000ffffffffffff1'),
(x'000ffffffffffffe'), (x'000fffffffffffff'))
select float8send(flt) as ibits,
flt
from (select bits::bigint::xfloat8::float8 as flt
from testdata
offset 0) s;
-- round-trip tests
with testdata(bits) as (values
(x'0000000000000000'),
-- smallest normal values
(x'0010000000000000'), (x'0010000000000001'),
(x'0010000000000002'), (x'0018000000000000'),
--
(x'3ddb7cdfd9d7bdba'), (x'3ddb7cdfd9d7bdbb'), (x'3ddb7cdfd9d7bdbc'),
(x'3e112e0be826d694'), (x'3e112e0be826d695'), (x'3e112e0be826d696'),
(x'3e45798ee2308c39'), (x'3e45798ee2308c3a'), (x'3e45798ee2308c3b'),
(x'3e7ad7f29abcaf47'), (x'3e7ad7f29abcaf48'), (x'3e7ad7f29abcaf49'),
(x'3eb0c6f7a0b5ed8c'), (x'3eb0c6f7a0b5ed8d'), (x'3eb0c6f7a0b5ed8e'),
(x'3ee4f8b588e368ef'), (x'3ee4f8b588e368f0'), (x'3ee4f8b588e368f1'),
(x'3f1a36e2eb1c432c'), (x'3f1a36e2eb1c432d'), (x'3f1a36e2eb1c432e'),
(x'3f50624dd2f1a9fb'), (x'3f50624dd2f1a9fc'), (x'3f50624dd2f1a9fd'),
(x'3f847ae147ae147a'), (x'3f847ae147ae147b'), (x'3f847ae147ae147c'),
(x'3fb9999999999999'), (x'3fb999999999999a'), (x'3fb999999999999b'),
-- values very close to 1
(x'3feffffffffffff0'), (x'3feffffffffffff1'), (x'3feffffffffffff2'),
(x'3feffffffffffff3'), (x'3feffffffffffff4'), (x'3feffffffffffff5'),
(x'3feffffffffffff6'), (x'3feffffffffffff7'), (x'3feffffffffffff8'),
(x'3feffffffffffff9'), (x'3feffffffffffffa'), (x'3feffffffffffffb'),
(x'3feffffffffffffc'), (x'3feffffffffffffd'), (x'3feffffffffffffe'),
(x'3fefffffffffffff'),
(x'3ff0000000000000'),
(x'3ff0000000000001'), (x'3ff0000000000002'), (x'3ff0000000000003'),
(x'3ff0000000000004'), (x'3ff0000000000005'), (x'3ff0000000000006'),
(x'3ff0000000000007'), (x'3ff0000000000008'), (x'3ff0000000000009'),
--
(x'3ff921fb54442d18'),
(x'4005bf0a8b14576a'),
(x'400921fb54442d18'),
--
(x'4023ffffffffffff'), (x'4024000000000000'), (x'4024000000000001'),
(x'4058ffffffffffff'), (x'4059000000000000'), (x'4059000000000001'),
(x'408f3fffffffffff'), (x'408f400000000000'), (x'408f400000000001'),
(x'40c387ffffffffff'), (x'40c3880000000000'), (x'40c3880000000001'),
(x'40f869ffffffffff'), (x'40f86a0000000000'), (x'40f86a0000000001'),
(x'412e847fffffffff'), (x'412e848000000000'), (x'412e848000000001'),
(x'416312cfffffffff'), (x'416312d000000000'), (x'416312d000000001'),
(x'4197d783ffffffff'), (x'4197d78400000000'), (x'4197d78400000001'),
(x'41cdcd64ffffffff'), (x'41cdcd6500000000'), (x'41cdcd6500000001'),
(x'4202a05f1fffffff'), (x'4202a05f20000000'), (x'4202a05f20000001'),
(x'42374876e7ffffff'), (x'42374876e8000000'), (x'42374876e8000001'),
(x'426d1a94a1ffffff'), (x'426d1a94a2000000'), (x'426d1a94a2000001'),
(x'42a2309ce53fffff'), (x'42a2309ce5400000'), (x'42a2309ce5400001'),
(x'42d6bcc41e8fffff'), (x'42d6bcc41e900000'), (x'42d6bcc41e900001'),
(x'430c6bf52633ffff'), (x'430c6bf526340000'), (x'430c6bf526340001'),
(x'4341c37937e07fff'), (x'4341c37937e08000'), (x'4341c37937e08001'),
(x'4376345785d89fff'), (x'4376345785d8a000'), (x'4376345785d8a001'),
(x'43abc16d674ec7ff'), (x'43abc16d674ec800'), (x'43abc16d674ec801'),
(x'43e158e460913cff'), (x'43e158e460913d00'), (x'43e158e460913d01'),
(x'4415af1d78b58c3f'), (x'4415af1d78b58c40'), (x'4415af1d78b58c41'),
(x'444b1ae4d6e2ef4f'), (x'444b1ae4d6e2ef50'), (x'444b1ae4d6e2ef51'),
(x'4480f0cf064dd591'), (x'4480f0cf064dd592'), (x'4480f0cf064dd593'),
(x'44b52d02c7e14af5'), (x'44b52d02c7e14af6'), (x'44b52d02c7e14af7'),
(x'44ea784379d99db3'), (x'44ea784379d99db4'), (x'44ea784379d99db5'),
(x'45208b2a2c280290'), (x'45208b2a2c280291'), (x'45208b2a2c280292'),
--
(x'7feffffffffffffe'), (x'7fefffffffffffff'),
-- round to even tests (+ve)
(x'4350000000000002'),
(x'4350000000002e06'),
(x'4352000000000003'),
(x'4352000000000004'),
(x'4358000000000003'),
(x'4358000000000004'),
(x'435f000000000020'),
-- round to even tests (-ve)
(x'c350000000000002'),
(x'c350000000002e06'),
(x'c352000000000003'),
(x'c352000000000004'),
(x'c358000000000003'),
(x'c358000000000004'),
(x'c35f000000000020'),
-- exercise fixed-point memmoves
(x'42dc12218377de66'),
(x'42a674e79c5fe51f'),
(x'4271f71fb04cb74c'),
(x'423cbe991a145879'),
(x'4206fee0e1a9e061'),
(x'41d26580b487e6b4'),
(x'419d6f34540ca453'),
(x'41678c29dcd6e9dc'),
(x'4132d687e3df217d'),
(x'40fe240c9fcb68c8'),
(x'40c81cd6e63c53d3'),
(x'40934a4584fd0fdc'),
(x'405edd3c07fb4c93'),
(x'4028b0fcd32f7076'),
(x'3ff3c0ca428c59f8'),
-- these cases come from the upstream's testsuite
-- LotsOfTrailingZeros)
(x'3e60000000000000'),
-- Regression
(x'c352bd2668e077c4'),
(x'434018601510c000'),
(x'43d055dc36f24000'),
(x'43e052961c6f8000'),
(x'3ff3c0ca2a5b1d5d'),
-- LooksLikePow5
(x'4830f0cf064dd592'),
(x'4840f0cf064dd592'),
(x'4850f0cf064dd592'),
-- OutputLength
(x'3ff3333333333333'),
(x'3ff3ae147ae147ae'),
(x'3ff3be76c8b43958'),
(x'3ff3c083126e978d'),
(x'3ff3c0c1fc8f3238'),
(x'3ff3c0c9539b8887'),
(x'3ff3c0ca2a5b1d5d'),
(x'3ff3c0ca4283de1b'),
(x'3ff3c0ca43db770a'),
(x'3ff3c0ca428abd53'),
(x'3ff3c0ca428c1d2b'),
(x'3ff3c0ca428c51f2'),
(x'3ff3c0ca428c58fc'),
(x'3ff3c0ca428c59dd'),
(x'3ff3c0ca428c59f8'),
(x'3ff3c0ca428c59fb'),
-- 32-bit chunking
(x'40112e0be8047a7d'),
(x'40112e0be815a889'),
(x'40112e0be826d695'),
(x'40112e0be83804a1'),
(x'40112e0be84932ad'),
-- MinMaxShift
(x'0040000000000000'),
(x'007fffffffffffff'),
(x'0290000000000000'),
(x'029fffffffffffff'),
(x'4350000000000000'),
(x'435fffffffffffff'),
(x'1330000000000000'),
(x'133fffffffffffff'),
(x'3a6fa7161a4d6e0c')
)
select float8send(flt) as ibits,
flt,
flt::text::float8 as r_flt,
float8send(flt::text::float8) as obits,
float8send(flt::text::float8) = float8send(flt) as correct
from (select bits::bigint::xfloat8::float8 as flt
from testdata
offset 0) s;
-- clean up, lest opr_sanity complain
\set VERBOSITY terse
drop type xfloat8 cascade;
\set VERBOSITY default
--

View File

@ -2,6 +2,9 @@
-- POINT
--
-- avoid bit-exact output here because operations may not be bit-exact.
SET extra_float_digits = 0;
CREATE TABLE POINT_TBL(f1 point);
INSERT INTO POINT_TBL(f1) VALUES ('(0.0,0.0)');

View File

@ -2,6 +2,9 @@
-- UPDATABLE VIEWS
--
-- avoid bit-exact output here because operations may not be bit-exact.
SET extra_float_digits = 0;
-- check that non-updatable views and columns are rejected with useful error
-- messages