Decimal128/256 rouding tests

This commit is contained in:
Igor Nikonov 2022-06-14 11:22:03 +00:00
parent bf7dd39282
commit 94116a1ee0
2 changed files with 26 additions and 0 deletions

View File

@ -73,3 +73,15 @@
12345678901234567890123456789.123456789 -12345678901234567890123456789.123456789 12345678901234567890123456790 -12345678901234567890123456789 12345678901234567890123457000 -12345678901234567890123456000
12345678901234567890123456789.123456789 -12345678901234567890123456789.123456789 12345678901234567890123456789 -12345678901234567890123456790 12345678901234567890123456000 -12345678901234567890123457000
12345678901234567890123456789.123456789 -12345678901234567890123456789.123456789 12345678901234567890123456789 -12345678901234567890123456789 12345678901234567890123456000 -12345678901234567890123456000
-- Decimal128, Scale 20
round() : 1234567890.123456789 -1234567890.123456789 1234567890 -1234567890 1234568000 -1234568000
roundBankers() : 1234567890.123456789 -1234567890.123456789 1234567890 -1234567890 1234568000 -1234568000
ceil() : 1234567890.123456789 -1234567890.123456789 1234567891 -1234567890 1234568000 -1234567000
floor() : 1234567890.123456789 -1234567890.123456789 1234567890 -1234567891 1234567000 -1234568000
trunc() : 1234567890.123456789 -1234567890.123456789 1234567890 -1234567890 1234567000 -1234567000
-- Decimal256, Scale 40
round() : 1234567890.123456789 -1234567890.123456789 1234567890 -1234567890 1234568000 -1234568000
roundBankers() : 1234567890.123456789 -1234567890.123456789 1234567890 -1234567890 1234568000 -1234568000
ceil() : 1234567890.123456789 -1234567890.123456789 1234567891 -1234567890 1234568000 -1234567000
floor() : 1234567890.123456789 -1234567890.123456789 1234567890 -1234567891 1234567000 -1234568000
trunc() : 1234567890.123456789 -1234567890.123456789 1234567890 -1234567890 1234567000 -1234567000

View File

@ -78,3 +78,17 @@ SELECT toDecimal128('12345678901234567890123456789.123456789', 9) AS x, -x AS y,
SELECT toDecimal128('12345678901234567890123456789.123456789', 9) AS x, -x AS y, ceil(x), ceil(y), ceil(x, -3), ceil(y, -3);
SELECT toDecimal128('12345678901234567890123456789.123456789', 9) AS x, -x AS y, floor(x), floor(y), floor(x, -3), floor(y, -3);
SELECT toDecimal128('12345678901234567890123456789.123456789', 9) AS x, -x AS y, trunc(x), trunc(y), trunc(x, -3), trunc(y, -3);
select '-- Decimal128, Scale 20';
SELECT 'round() : ', toDecimal128('1234567890.123456789', 20) AS x, -x AS y, round(x), round(y), round(x, -3), round(y, -3);
SELECT 'roundBankers() : ', toDecimal128('1234567890.123456789', 20) AS x, -x AS y, roundBankers(x), roundBankers(y), roundBankers(x, -3), roundBankers(y, -3);
SELECT 'ceil() : ', toDecimal128('1234567890.123456789', 20) AS x, -x AS y, ceil(x), ceil(y), ceil(x, -3), ceil(y, -3);
SELECT 'floor() : ', toDecimal128('1234567890.123456789', 20) AS x, -x AS y, floor(x), floor(y), floor(x, -3), floor(y, -3);
SELECT 'trunc() : ', toDecimal128('1234567890.123456789', 20) AS x, -x AS y, trunc(x), trunc(y), trunc(x, -3), trunc(y, -3);
select '-- Decimal256, Scale 40';
SELECT 'round() : ', toDecimal256('1234567890.123456789', 40) AS x, -x AS y, round(x), round(y), round(x, -3), round(y, -3);
SELECT 'roundBankers() : ', toDecimal256('1234567890.123456789', 40) AS x, -x AS y, roundBankers(x), roundBankers(y), roundBankers(x, -3), roundBankers(y, -3);
SELECT 'ceil() : ', toDecimal256('1234567890.123456789', 40) AS x, -x AS y, ceil(x), ceil(y), ceil(x, -3), ceil(y, -3);
SELECT 'floor() : ', toDecimal256('1234567890.123456789', 40) AS x, -x AS y, floor(x), floor(y), floor(x, -3), floor(y, -3);
SELECT 'trunc() : ', toDecimal256('1234567890.123456789', 40) AS x, -x AS y, trunc(x), trunc(y), trunc(x, -3), trunc(y, -3);