Skip to content

Commit

Permalink
ORC-1738: [C++] Fix wrong Int128 maximum value
Browse files Browse the repository at this point in the history
### 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]>
  • Loading branch information
letian-jiang authored and dongjoon-hyun committed Jul 9, 2024
1 parent cccbe72 commit 9af09ec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion c++/src/Int128.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
namespace orc {

Int128 Int128::maximumValue() {
return Int128(0x7fffffffffffffff, 0xfffffffffffffff);
return Int128(0x7fffffffffffffff, 0xffffffffffffffff);
}

Int128 Int128::minimumValue() {
Expand Down
5 changes: 5 additions & 0 deletions c++/test/TestInt128.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 9af09ec

Please sign in to comment.