1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-26 23:43:30 +03:00

This patch adds some missing functions for float8 math operations,

specifically ceil(), floor(), and sign(). There may be other functions
that need to be added, but this is a start. I've included some simple
regression tests.

Neil Conway
This commit is contained in:
Bruce Momjian
2002-10-19 02:08:19 +00:00
parent 5c6a5fe18b
commit bab3d29fba
7 changed files with 119 additions and 19 deletions

View File

@@ -149,13 +149,46 @@ SELECT '' AS five, f.f1, f.f1 % AS round_f1
| 1.2345678901234e-200 | 0
(5 rows)
-- ceil
select ceil(f1) as ceil_f1 from float8_tbl f;
ceil_f1
----------------------
0
1005
-34
1.2345678901234e+200
1
(5 rows)
-- floor
select floor(f1) as floor_f1 from float8_tbl f;
floor_f1
----------------------
0
1004
-35
1.2345678901234e+200
0
(5 rows)
-- sign
select sign(f1) as sign_f1 from float8_tbl f;
sign_f1
---------
0
1
-1
1
1
(5 rows)
-- square root
SELECT sqrt(float8 '64') AS eight;
eight
-------
8
(1 row)
-- square root
SELECT |/ float8 '64' AS eight;
eight
-------

View File

@@ -60,9 +60,18 @@ SELECT '' AS five, f.f1, %f.f1 AS trunc_f1
SELECT '' AS five, f.f1, f.f1 % AS round_f1
FROM FLOAT8_TBL f;
SELECT sqrt(float8 '64') AS eight;
-- ceil
select ceil(f1) as ceil_f1 from float8_tbl f;
-- floor
select floor(f1) as floor_f1 from float8_tbl f;
-- sign
select sign(f1) as sign_f1 from float8_tbl f;
-- square root
SELECT sqrt(float8 '64') AS eight;
SELECT |/ float8 '64' AS eight;
SELECT '' AS three, f.f1, |/f.f1 AS sqrt_f1