This is an automated email from the ASF dual-hosted git repository.

dongjoon pushed a commit to branch branch-1.7
in repository https://gitbox.apache.org/repos/asf/orc.git


The following commit(s) were added to refs/heads/branch-1.7 by this push:
     new 6047d4e16 ORC-1738: [C++] Fix wrong Int128 maximum value
6047d4e16 is described below

commit 6047d4e16963029fdfc96055ee930bdbe0089184
Author: Letian Jiang <[email protected]>
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 <[email protected]>
    Signed-off-by: Dongjoon Hyun <[email protected]>
    (cherry picked from commit 9af09ec8be4e526b0ee978fea02314479a6f315d)
    Signed-off-by: Dongjoon Hyun <[email protected]>
---
 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 4ff500fba..8d557d2ca 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 f72eeee35..079da95d4 100644
--- a/c++/test/TestInt128.cc
+++ b/c++/test/TestInt128.cc
@@ -558,6 +558,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) {

Reply via email to