This is an automated email from the ASF dual-hosted git repository. dongjoon pushed a commit to branch branch-1.9 in repository https://gitbox.apache.org/repos/asf/orc.git
The following commit(s) were added to refs/heads/branch-1.9 by this push: new 552b9656f ORC-1738: [C++] Fix wrong Int128 maximum value 552b9656f is described below commit 552b9656ff2f1d3e2ac2a871ac30cc8e51d94c60 Author: Letian Jiang <letian.ji...@outlook.com> AuthorDate: Tue Jul 9 12:24:20 2024 -0700 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 <letian.ji...@outlook.com> Signed-off-by: Dongjoon Hyun <dongj...@apache.org> (cherry picked from commit 9af09ec8be4e526b0ee978fea02314479a6f315d) Signed-off-by: Dongjoon Hyun <dongj...@apache.org> --- 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 327930975..8fb4627b5 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 ca67522d8..6d5c7f6e8 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) {