diff options
Diffstat (limited to 'src/test/regress')
-rw-r--r-- | src/test/regress/expected/numeric.out | 102 | ||||
-rw-r--r-- | src/test/regress/sql/numeric.sql | 25 |
2 files changed, 127 insertions, 0 deletions
diff --git a/src/test/regress/expected/numeric.out b/src/test/regress/expected/numeric.out index 72f03c8a38a..f30ac236f52 100644 --- a/src/test/regress/expected/numeric.out +++ b/src/test/regress/expected/numeric.out @@ -1346,6 +1346,108 @@ FROM generate_series(-5,5) AS t(i); 5 | -300000 | -200000 | -100000 | 100000 | 200000 | 300000 (11 rows) +-- Check limits of rounding before the decimal point +SELECT round(4.4e131071, -131071) = 4e131071; + ?column? +---------- + t +(1 row) + +SELECT round(4.5e131071, -131071) = 5e131071; + ?column? +---------- + t +(1 row) + +SELECT round(4.5e131071, -131072); -- loses all digits + round +------- + 0 +(1 row) + +SELECT round(5.5e131071, -131072); -- rounds up and overflows +ERROR: value overflows numeric format +SELECT round(5.5e131071, -131073); -- loses all digits + round +------- + 0 +(1 row) + +SELECT round(5.5e131071, -1000000); -- loses all digits + round +------- + 0 +(1 row) + +-- Check limits of rounding after the decimal point +SELECT round(5e-16383, 1000000) = 5e-16383; + ?column? +---------- + t +(1 row) + +SELECT round(5e-16383, 16383) = 5e-16383; + ?column? +---------- + t +(1 row) + +SELECT round(5e-16383, 16382) = 1e-16382; + ?column? +---------- + t +(1 row) + +SELECT round(5e-16383, 16381) = 0; + ?column? +---------- + t +(1 row) + +-- Check limits of trunc() before the decimal point +SELECT trunc(9.9e131071, -131071) = 9e131071; + ?column? +---------- + t +(1 row) + +SELECT trunc(9.9e131071, -131072); -- loses all digits + trunc +------- + 0 +(1 row) + +SELECT trunc(9.9e131071, -131073); -- loses all digits + trunc +------- + 0 +(1 row) + +SELECT trunc(9.9e131071, -1000000); -- loses all digits + trunc +------- + 0 +(1 row) + +-- Check limits of trunc() after the decimal point +SELECT trunc(5e-16383, 1000000) = 5e-16383; + ?column? +---------- + t +(1 row) + +SELECT trunc(5e-16383, 16383) = 5e-16383; + ?column? +---------- + t +(1 row) + +SELECT trunc(5e-16383, 16382) = 0; + ?column? +---------- + t +(1 row) + -- Testing for width_bucket(). For convenience, we test both the -- numeric and float8 versions of the function in this file. -- errors diff --git a/src/test/regress/sql/numeric.sql b/src/test/regress/sql/numeric.sql index 83fc386333b..c86395209ab 100644 --- a/src/test/regress/sql/numeric.sql +++ b/src/test/regress/sql/numeric.sql @@ -833,6 +833,31 @@ SELECT i as pow, round((2.5 * 10 ^ i)::numeric, -i) FROM generate_series(-5,5) AS t(i); +-- Check limits of rounding before the decimal point +SELECT round(4.4e131071, -131071) = 4e131071; +SELECT round(4.5e131071, -131071) = 5e131071; +SELECT round(4.5e131071, -131072); -- loses all digits +SELECT round(5.5e131071, -131072); -- rounds up and overflows +SELECT round(5.5e131071, -131073); -- loses all digits +SELECT round(5.5e131071, -1000000); -- loses all digits + +-- Check limits of rounding after the decimal point +SELECT round(5e-16383, 1000000) = 5e-16383; +SELECT round(5e-16383, 16383) = 5e-16383; +SELECT round(5e-16383, 16382) = 1e-16382; +SELECT round(5e-16383, 16381) = 0; + +-- Check limits of trunc() before the decimal point +SELECT trunc(9.9e131071, -131071) = 9e131071; +SELECT trunc(9.9e131071, -131072); -- loses all digits +SELECT trunc(9.9e131071, -131073); -- loses all digits +SELECT trunc(9.9e131071, -1000000); -- loses all digits + +-- Check limits of trunc() after the decimal point +SELECT trunc(5e-16383, 1000000) = 5e-16383; +SELECT trunc(5e-16383, 16383) = 5e-16383; +SELECT trunc(5e-16383, 16382) = 0; + -- Testing for width_bucket(). For convenience, we test both the -- numeric and float8 versions of the function in this file. |