This is an automated email from the ASF dual-hosted git repository.
dongjoon pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/orc.git
The following commit(s) were added to refs/heads/main by this push:
new 9af09ec8b ORC-1738: [C++] Fix wrong Int128 maximum value
9af09ec8b is described below
commit 9af09ec8be4e526b0ee978fea02314479a6f315d
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]>
---
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 4a1d0b763..1e059fd4e 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 54dcff456..be5b65b3a 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) {