+++ /dev/null
---
--- FLOAT8
---
-CREATE TABLE FLOAT8_TBL(f1 float8);
-INSERT INTO FLOAT8_TBL(f1) VALUES ('0.0');
-INSERT INTO FLOAT8_TBL(f1) VALUES ('1004.30');
-INSERT INTO FLOAT8_TBL(f1) VALUES ('-34.84');
-INSERT INTO FLOAT8_TBL(f1) VALUES ('1.2345678901234e+200');
-INSERT INTO FLOAT8_TBL(f1) VALUES ('1.2345678901234e-200');
-SELECT '' AS five, FLOAT8_TBL.*;
- five | f1
-------+----------------------
- | 0
- | 1004.3
- | -34.84
- | 1.2345678901234e+200
- | 1.2345678901234e-200
-(5 rows)
-
-SELECT '' AS four, f.* FROM FLOAT8_TBL f WHERE f.f1 <> '1004.3';
- four | f1
-------+----------------------
- | 0
- | -34.84
- | 1.2345678901234e+200
- | 1.2345678901234e-200
-(4 rows)
-
-SELECT '' AS one, f.* FROM FLOAT8_TBL f WHERE f.f1 = '1004.3';
- one | f1
------+--------
- | 1004.3
-(1 row)
-
-SELECT '' AS three, f.* FROM FLOAT8_TBL f WHERE '1004.3' > f.f1;
- three | f1
--------+----------------------
- | 0
- | -34.84
- | 1.2345678901234e-200
-(3 rows)
-
-SELECT '' AS three, f.* FROM FLOAT8_TBL f WHERE f.f1 < '1004.3';
- three | f1
--------+----------------------
- | 0
- | -34.84
- | 1.2345678901234e-200
-(3 rows)
-
-SELECT '' AS four, f.* FROM FLOAT8_TBL f WHERE '1004.3' >= f.f1;
- four | f1
-------+----------------------
- | 0
- | 1004.3
- | -34.84
- | 1.2345678901234e-200
-(4 rows)
-
-SELECT '' AS four, f.* FROM FLOAT8_TBL f WHERE f.f1 <= '1004.3';
- four | f1
-------+----------------------
- | 0
- | 1004.3
- | -34.84
- | 1.2345678901234e-200
-(4 rows)
-
-SELECT '' AS three, f.f1, f.f1 * '-10' AS x
- FROM FLOAT8_TBL f
- WHERE f.f1 > '0.0';
- three | f1 | x
--------+----------------------+-----------------------
- | 1004.3 | -10043
- | 1.2345678901234e+200 | -1.2345678901234e+201
- | 1.2345678901234e-200 | -1.2345678901234e-199
-(3 rows)
-
-SELECT '' AS three, f.f1, f.f1 + '-10' AS x
- FROM FLOAT8_TBL f
- WHERE f.f1 > '0.0';
- three | f1 | x
--------+----------------------+----------------------
- | 1004.3 | 994.3
- | 1.2345678901234e+200 | 1.2345678901234e+200
- | 1.2345678901234e-200 | -10
-(3 rows)
-
-SELECT '' AS three, f.f1, f.f1 / '-10' AS x
- FROM FLOAT8_TBL f
- WHERE f.f1 > '0.0';
- three | f1 | x
--------+----------------------+-----------------------
- | 1004.3 | -100.43
- | 1.2345678901234e+200 | -1.2345678901234e+199
- | 1.2345678901234e-200 | -1.2345678901234e-201
-(3 rows)
-
-SELECT '' AS three, f.f1, f.f1 - '-10' AS x
- FROM FLOAT8_TBL f
- WHERE f.f1 > '0.0';
- three | f1 | x
--------+----------------------+----------------------
- | 1004.3 | 1014.3
- | 1.2345678901234e+200 | 1.2345678901234e+200
- | 1.2345678901234e-200 | 10
-(3 rows)
-
-SELECT '' AS one, f.f1 ^ '2.0' AS square_f1
- FROM FLOAT8_TBL f where f.f1 = '1004.3';
- one | square_f1
------+------------
- | 1008618.49
-(1 row)
-
--- absolute value
-SELECT '' AS five, f.f1, @f.f1 AS abs_f1
- FROM FLOAT8_TBL f;
- five | f1 | abs_f1
-------+----------------------+----------------------
- | 0 | 0
- | 1004.3 | 1004.3
- | -34.84 | 34.84
- | 1.2345678901234e+200 | 1.2345678901234e+200
- | 1.2345678901234e-200 | 1.2345678901234e-200
-(5 rows)
-
--- truncate
-SELECT '' AS five, f.f1, %f.f1 AS trunc_f1
- FROM FLOAT8_TBL f;
- five | f1 | trunc_f1
-------+----------------------+----------------------
- | 0 | 0
- | 1004.3 | 1004
- | -34.84 | -34
- | 1.2345678901234e+200 | 1.2345678901234e+200
- | 1.2345678901234e-200 | 0
-(5 rows)
-
--- round
-SELECT '' AS five, f.f1, f.f1 % AS round_f1
- FROM FLOAT8_TBL f;
- five | f1 | round_f1
-------+----------------------+----------------------
- | 0 | 0
- | 1004.3 | 1004
- | -34.84 | -35
- | 1.2345678901234e+200 | 1.2345678901234e+200
- | 1.2345678901234e-200 | 0
-(5 rows)
-
-SELECT sqrt(float8 '64') AS eight;
- eight
--------
- 8
-(1 row)
-
--- square root
-SELECT |/ float8 '64' AS eight;
- eight
--------
- 8
-(1 row)
-
-SELECT '' AS three, f.f1, |/f.f1 AS sqrt_f1
- FROM FLOAT8_TBL f
- WHERE f.f1 > '0.0';
- three | f1 | sqrt_f1
--------+----------------------+-----------------------
- | 1004.3 | 31.6906926399535
- | 1.2345678901234e+200 | 1.11111110611109e+100
- | 1.2345678901234e-200 | 1.11111110611109e-100
-(3 rows)
-
--- take exp of ln(f.f1)
-SELECT '' AS three, f.f1, exp(ln(f.f1)) AS exp_ln_f1
- FROM FLOAT8_TBL f
- WHERE f.f1 > '0.0';
- three | f1 | exp_ln_f1
--------+----------------------+-----------------------
- | 1004.3 | 1004.3
- | 1.2345678901234e+200 | 1.23456789012338e+200
- | 1.2345678901234e-200 | 1.23456789012339e-200
-(3 rows)
-
--- cube root
-SELECT ||/ float8 '27' AS three;
- three
--------
- 3
-(1 row)
-
-SELECT '' AS five, f.f1, ||/f.f1 AS cbrt_f1 FROM FLOAT8_TBL f;
- five | f1 | cbrt_f1
-------+----------------------+----------------------
- | 0 | 0
- | 1004.3 | 10.014312837827
- | -34.84 | -3.26607421344208
- | 1.2345678901234e+200 | 4.97933859234765e+66
- | 1.2345678901234e-200 | 2.3112042409018e-67
-(5 rows)
-
-SELECT '' AS five, FLOAT8_TBL.*;
- five | f1
-------+----------------------
- | 0
- | 1004.3
- | -34.84
- | 1.2345678901234e+200
- | 1.2345678901234e-200
-(5 rows)
-
-UPDATE FLOAT8_TBL
- SET f1 = FLOAT8_TBL.f1 * '-1'
- WHERE FLOAT8_TBL.f1 > '0.0';
-SELECT '' AS bad, f.f1 * '1e200' from FLOAT8_TBL f;
-ERROR: Bad float8 input format -- overflow
-SELECT '' AS bad, f.f1 ^ '1e200' from FLOAT8_TBL f;
-ERROR: pow() result is out of range
-SELECT '' AS bad, ln(f.f1) from FLOAT8_TBL f where f.f1 = '0.0' ;
-ERROR: can't take log of zero
-SELECT '' AS bad, ln(f.f1) from FLOAT8_TBL f where f.f1 < '0.0' ;
-ERROR: can't take log of a negative number
-SELECT '' AS bad, exp(f.f1) from FLOAT8_TBL f;
-ERROR: exp() result is out of range
-SELECT '' AS bad, f.f1 / '0.0' from FLOAT8_TBL f;
-ERROR: float8div: divide by zero error
-SELECT '' AS five, FLOAT8_TBL.*;
- five | f1
-------+-----------------------
- | 0
- | -34.84
- | -1004.3
- | -1.2345678901234e+200
- | -1.2345678901234e-200
-(5 rows)
-
--- test for over- and underflow
-INSERT INTO FLOAT8_TBL(f1) VALUES ('10e400');
-ERROR: Input '10e400' is out of range for float8
-INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e400');
-ERROR: Input '-10e400' is out of range for float8
-INSERT INTO FLOAT8_TBL(f1) VALUES ('10e-400');
-INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e-400');
--- maintain external table consistency across platforms
--- delete all values and reinsert well-behaved ones
-DELETE FROM FLOAT8_TBL;
-INSERT INTO FLOAT8_TBL(f1) VALUES ('0.0');
-INSERT INTO FLOAT8_TBL(f1) VALUES ('-34.84');
-INSERT INTO FLOAT8_TBL(f1) VALUES ('-1004.30');
-INSERT INTO FLOAT8_TBL(f1) VALUES ('-1.2345678901234e+200');
-INSERT INTO FLOAT8_TBL(f1) VALUES ('-1.2345678901234e-200');
-SELECT '' AS five, FLOAT8_TBL.*;
- five | f1
-------+-----------------------
- | 0
- | -34.84
- | -1004.3
- | -1.2345678901234e+200
- | -1.2345678901234e-200
-(5 rows)
-
twentyfour | translation
------------+-------------------------
| (2,2),(0,0)
- | (-8,2),(-10,0)
- | (-1,6),(-3,4)
- | (7.1,36.5),(5.1,34.5)
- | (-3,-10),(-5,-12)
- | (12,12),(10,10)
| (3,3),(1,1)
- | (-7,3),(-9,1)
- | (0,7),(-2,5)
- | (8.1,37.5),(6.1,35.5)
- | (-2,-9),(-4,-11)
- | (13,13),(11,11)
| (2.5,3.5),(2.5,2.5)
- | (-7.5,3.5),(-7.5,2.5)
- | (-0.5,7.5),(-0.5,6.5)
- | (7.6,38),(7.6,37)
- | (-2.5,-8.5),(-2.5,-9.5)
- | (12.5,13.5),(12.5,12.5)
| (3,3),(3,3)
+ | (-8,2),(-10,0)
+ | (-7,3),(-9,1)
+ | (-7.5,3.5),(-7.5,2.5)
| (-7,3),(-7,3)
+ | (-1,6),(-3,4)
+ | (0,7),(-2,5)
+ | (-0.5,7.5),(-0.5,6.5)
| (0,7),(0,7)
+ | (7.1,36.5),(5.1,34.5)
+ | (8.1,37.5),(6.1,35.5)
+ | (7.6,38),(7.6,37)
| (8.1,37.5),(8.1,37.5)
+ | (-3,-10),(-5,-12)
+ | (-2,-9),(-4,-11)
+ | (-2.5,-8.5),(-2.5,-9.5)
| (-2,-9),(-2,-9)
+ | (12,12),(10,10)
+ | (13,13),(11,11)
+ | (12.5,13.5),(12.5,12.5)
| (13,13),(13,13)
(24 rows)
twentyfour | translation
------------+---------------------------
| (2,2),(0,0)
- | (12,2),(10,0)
- | (5,-2),(3,-4)
- | (-3.1,-32.5),(-5.1,-34.5)
- | (7,14),(5,12)
- | (-8,-8),(-10,-10)
| (3,3),(1,1)
- | (13,3),(11,1)
- | (6,-1),(4,-3)
- | (-2.1,-31.5),(-4.1,-33.5)
- | (8,15),(6,13)
- | (-7,-7),(-9,-9)
| (2.5,3.5),(2.5,2.5)
- | (12.5,3.5),(12.5,2.5)
- | (5.5,-0.5),(5.5,-1.5)
- | (-2.6,-31),(-2.6,-32)
- | (7.5,15.5),(7.5,14.5)
- | (-7.5,-6.5),(-7.5,-7.5)
| (3,3),(3,3)
+ | (12,2),(10,0)
+ | (13,3),(11,1)
+ | (12.5,3.5),(12.5,2.5)
| (13,3),(13,3)
+ | (5,-2),(3,-4)
+ | (6,-1),(4,-3)
+ | (5.5,-0.5),(5.5,-1.5)
| (6,-1),(6,-1)
+ | (-3.1,-32.5),(-5.1,-34.5)
+ | (-2.1,-31.5),(-4.1,-33.5)
+ | (-2.6,-31),(-2.6,-32)
| (-2.1,-31.5),(-2.1,-31.5)
+ | (7,14),(5,12)
+ | (8,15),(6,13)
+ | (7.5,15.5),(7.5,14.5)
| (8,15),(8,15)
+ | (-8,-8),(-10,-10)
+ | (-7,-7),(-9,-9)
+ | (-7.5,-6.5),(-7.5,-7.5)
| (-7,-7),(-7,-7)
(24 rows)
twentyfour | rotation
------------+-----------------------------
| (0,0),(0,0)
- | (-0,0),(-20,-20)
- | (-0,2),(-14,0)
- | (0,79.2),(-58.8,0)
- | (14,-0),(0,-34)
- | (0,40),(0,0)
| (0,0),(0,0)
- | (-10,-10),(-30,-30)
- | (-7,3),(-21,1)
- | (-29.4,118.8),(-88.2,39.6)
- | (21,-17),(7,-51)
- | (0,60),(0,20)
| (0,0),(0,0)
- | (-25,-25),(-25,-35)
- | (-17.5,2.5),(-21.5,-0.5)
- | (-73.5,104.1),(-108,99)
- | (29.5,-42.5),(17.5,-47.5)
- | (0,60),(-10,50)
| (0,0),(0,0)
+ | (-0,0),(-20,-20)
+ | (-10,-10),(-30,-30)
+ | (-25,-25),(-25,-35)
| (-30,-30),(-30,-30)
+ | (-0,2),(-14,0)
+ | (-7,3),(-21,1)
+ | (-17.5,2.5),(-21.5,-0.5)
| (-21,3),(-21,3)
+ | (0,79.2),(-58.8,0)
+ | (-29.4,118.8),(-88.2,39.6)
+ | (-73.5,104.1),(-108,99)
| (-88.2,118.8),(-88.2,118.8)
+ | (14,-0),(0,-34)
+ | (21,-17),(7,-51)
+ | (29.5,-42.5),(17.5,-47.5)
| (21,-51),(21,-51)
+ | (0,40),(0,0)
+ | (0,60),(0,20)
+ | (0,60),(-10,50)
| (0,60),(0,60)
(24 rows)
six | polygon
-----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| ((-3,0),(-2.59807621135076,1.50000000000442),(-1.49999999999116,2.59807621135842),(1.53102359017709e-11,3),(1.50000000001768,2.59807621134311),(2.59807621136607,1.4999999999779),(3,-3.06204718035418e-11),(2.59807621133545,-1.50000000003094),(1.49999999996464,-2.59807621137373),(-4.59307077053127e-11,-3),(-1.5000000000442,-2.5980762113278),(-2.59807621138138,-1.49999999995138))
- | ((-99,2),(-85.6025403783588,52.0000000001473),(-48.9999999997054,88.602540378614),(1.00000000051034,102),(51.0000000005893,88.6025403781036),(87.6025403788692,51.9999999992634),(101,1.99999999897932),(87.6025403778485,-48.0000000010313),(50.9999999988214,-84.6025403791243),(0.999999998468976,-98),(-49.0000000014732,-84.6025403775933),(-85.6025403793795,-47.9999999983795))
+ | ((-99,2),(-85.6025403783588,52.0000000001473),(-48.9999999997054,88.602540378614),(1.00000000051034,102),(51.0000000005893,88.6025403781036),(87.6025403788692,51.9999999992634),(101,1.99999999897932),(87.6025403778485,-48.0000000010313),(50.9999999988214,-84.6025403791243),(0.999999998468976,-98),(-49.0000000014732,-84.6025403775933),(-85.6025403793795,-47.9999999983794))
| ((-4,3),(-3.33012701891794,5.50000000000737),(-1.49999999998527,7.3301270189307),(1.00000000002552,8),(3.50000000002946,7.33012701890518),(5.33012701894346,5.49999999996317),(6,2.99999999994897),(5.33012701889242,0.499999999948437),(3.49999999994107,-1.33012701895622),(0.999999999923449,-2),(-1.50000000007366,-1.33012701887967),(-3.33012701896897,0.500000000081028))
- | ((-2,2),(-1.59807621135076,3.50000000000442),(-0.499999999991161,4.59807621135842),(1.00000000001531,5),(2.50000000001768,4.59807621134311),(3.59807621136607,3.4999999999779),(4,1.99999999996938),(3.59807621133545,0.499999999969062),(2.49999999996464,-0.598076211373729),(0.999999999954069,-1),(-0.500000000044197,-0.598076211327799),(-1.59807621138138,0.500000000048616))
+ | ((-2,2),(-1.59807621135076,3.50000000000442),(-0.499999999991161,4.59807621135842),(1.00000000001531,5),(2.50000000001768,4.59807621134311),(3.59807621136607,3.4999999999779),(4,1.99999999996938),(3.59807621133545,0.499999999969062),(2.49999999996464,-0.598076211373729),(0.999999999954069,-1),(-0.500000000044197,-0.598076211327799),(-1.59807621138138,0.500000000048617))
| ((90,200),(91.3397459621641,205.000000000015),(95.0000000000295,208.660254037861),(100.000000000051,210),(105.000000000059,208.66025403781),(108.660254037887,204.999999999926),(110,199.999999999898),(108.660254037785,194.999999999897),(104.999999999882,191.339745962088),(99.9999999998469,190),(94.9999999998527,191.339745962241),(91.3397459620621,195.000000000162))
- | ((0,0),(13.3974596216412,50.0000000001473),(50.0000000002946,86.602540378614),(100.00000000051,100),(150.000000000589,86.6025403781036),(186.602540378869,49.9999999992634),(200,-1.02068239345139e-09),(186.602540377848,-50.0000000010313),(149.999999998821,-86.6025403791243),(99.999999998469,-100),(49.9999999985268,-86.6025403775933),(13.3974596206205,-49.9999999983795))
+ | ((0,0),(13.3974596216412,50.0000000001473),(50.0000000002946,86.602540378614),(100.00000000051,100),(150.000000000589,86.6025403781036),(186.602540378869,49.9999999992634),(200,-1.02068239345139e-09),(186.602540377848,-50.0000000010313),(149.999999998821,-86.6025403791243),(99.999999998469,-100),(49.9999999985268,-86.6025403775933),(13.3974596206205,-49.9999999983794))
(6 rows)
-- convert the circle to an 8-point polygon