From 9af09ec8be4e526b0ee978fea02314479a6f315d Mon Sep 17 00:00:00 2001 From: Letian Jiang Date: Tue, 9 Jul 2024 12:24:20 -0700 Subject: [PATCH] ORC-1738: [C++] Fix wrong Int128 maximum value ### What changes were proposed in this pull request? ### Why are the changes needed? The low part of Int128::maximumValue is wrong. In hex format, it should be 0xffffffffffffffff rather than 0xfffffffffffffff, in which one f is dropped by mistake. ### How was this patch tested? I have added the relevant unit tests. ### Was this patch authored or co-authored using generative AI tooling? No. Closes #1970 from letian-jiang/fix-128-max. Authored-by: Letian Jiang Signed-off-by: Dongjoon Hyun --- c++/src/Int128.cc | 2 +- c++/test/TestInt128.cc | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/c++/src/Int128.cc b/c++/src/Int128.cc index 4a1d0b763a..1e059fd4e2 100644 --- a/c++/src/Int128.cc +++ b/c++/src/Int128.cc @@ -27,7 +27,7 @@ namespace orc { Int128 Int128::maximumValue() { - return Int128(0x7fffffffffffffff, 0xfffffffffffffff); + return Int128(0x7fffffffffffffff, 0xffffffffffffffff); } Int128 Int128::minimumValue() { diff --git a/c++/test/TestInt128.cc b/c++/test/TestInt128.cc index 54dcff4567..be5b65b3a7 100644 --- a/c++/test/TestInt128.cc +++ b/c++/test/TestInt128.cc @@ -555,6 +555,11 @@ namespace orc { num = Int128("-12345678901122334455667788990011122233"); EXPECT_EQ("-12345678901122334455667788990011122233", num.toString()); + + num = Int128::maximumValue(); + EXPECT_EQ("170141183460469231731687303715884105727", num.toString()); + num = Int128::minimumValue(); + EXPECT_EQ("-170141183460469231731687303715884105728", num.toString()); } TEST(Int128, testToDecimalString) {