-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Use a range of 2^63/10+1 to 2^63-1 for large mantissas #6275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
3094798 to
c01bfb2
Compare
3934fdb to
b0d8b61
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #6275 +/- ##
=======================================
Coverage 79.9% 79.9%
=======================================
Files 840 840
Lines 65549 65556 +7
Branches 7266 7266
=======================================
+ Hits 52351 52357 +6
- Misses 13198 13199 +1
🚀 New features to boost your workflow:
|
7275749 to
6fcb32e
Compare
- That makes minMantissa 2^63/10+1. - Simplifies many of the existing operations, and removes the need for the accessors (mantissa() & exponent()) to do any math.
…number-maxint-range * commit '5f638f55536def0d88b970d1018a465a238e55f4': chore: Set ColumnLimit to 120 in clang-format (6288)
…axint-range * upstream/develop: chore: Update secp256k1 and openssl (6327) chore: Remove unnecessary script (6326) refactor: Replace include guards by '#pragma once' (6322) chore: Remove unity builds (6300) refactor: Add ServiceRegistry to help modularization (6222) fix: Deletes expired NFToken offers from ledger (5707) chore: Add .zed editor config directory to .gitignore (6317) docs: Update API changelog, add APIv2+APIv3 version documentation (6308) fix: Restore config changes that broke standalone mode (6301) chore: Add upper-case match for ARM64 in CompilationEnv (6315) ci: Update hashes of XRPLF/actions (6316) chore: Format all cmake files without comments (6294) chore: Add cmake-format pre-commit hook (6279) chore: Remove unnecessary `boost::system` requirement from conanfile (6290)
9457b82 to
154bb65
Compare
9a26fdb to
07c0c32
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors the Number class to use a signed int64 mantissa instead of an unsigned mantissa with a separate boolean sign flag. The large mantissa range changes from [10^18, 10^19-1] to [2^63/10+1, 2^63-1], which allows all Number class member variables to fit within signed int64 and int types, reducing the memory footprint.
Changes:
- Changed Number class mantissa representation from
bool negative_+uint64_t mantissa_to a singleint64_t mantissa_ - Updated MantissaRange calculations to use [2^63/10+1, 2^63-1] for the large range
- Refactored internal representation handling with new
toInternal()andfromInternal()helper functions - Updated all arithmetic operations and utility functions to work with signed mantissa
- Comprehensive test updates to verify new mantissa range behavior
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
| include/xrpl/basics/Number.h | Updated Number class to use signed mantissa, removed negative_ flag, refactored MantissaRange struct, added helper functions for internal/external conversion |
| src/libxrpl/basics/Number.cpp | Updated all arithmetic operations and normalization logic to work with signed mantissa, added toInternal/fromInternal implementations |
| src/test/basics/Number_test.cpp | Updated test cases for new mantissa range, added new test function testNormalizeToRange, updated expected values throughout |
| include/xrpl/protocol/SystemParameters.h | Changed maxRep reference to largestMantissa |
| include/xrpl/protocol/Protocol.h | Changed maxRep reference to largestMantissa |
| include/xrpl/protocol/STAmount.h | Added assertion for non-negative Number before normalization |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Update explanations. - Use saver conversions between signed and unsigned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
include/xrpl/basics/Number.h
Outdated
| return std::make_pair(sign * static_cast<T>(mantissa), exponent); | ||
| } | ||
|
|
Copilot
AI
Feb 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unreachable return statement. The previous line (869) already returns, making this line dead code. This second return statement should be removed.
| return std::make_pair(sign * static_cast<T>(mantissa), exponent); | |
| } | |
| } |
include/xrpl/basics/Number.h
Outdated
| #if MAXREP | ||
| constexpr static internalrep maxRep = std::numeric_limits<rep>::max(); | ||
| static_assert(maxRep == 9'223'372'036'854'775'807); | ||
| static_assert(-maxRep == std::numeric_limits<rep>::min() + 1); | ||
| #endif |
Copilot
AI
Feb 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The preprocessor conditional 'MAXREP' appears to be undefined. These conditional blocks will never be included in the build unless MAXREP is defined elsewhere. Either define MAXREP appropriately or remove these conditional compilation directives if they're no longer needed.
include/xrpl/basics/Number.h
Outdated
| #if MAXREP | ||
| static_assert(smallRange.min < maxRep); | ||
| static_assert(smallRange.max < maxRep); | ||
| #endif |
Copilot
AI
Feb 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The preprocessor conditional 'MAXREP' appears to be undefined. These conditional blocks will never be included in the build unless MAXREP is defined elsewhere. Either define MAXREP appropriately or remove these conditional compilation directives if they're no longer needed.
include/xrpl/basics/Number.h
Outdated
| #if MAXREP | ||
| static_assert(largeRange.min < maxRep); | ||
| static_assert(largeRange.max > maxRep); | ||
| #endif |
Copilot
AI
Feb 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The preprocessor conditional 'MAXREP' appears to be undefined. These conditional blocks will never be included in the build unless MAXREP is defined elsewhere. Either define MAXREP appropriately or remove these conditional compilation directives if they're no longer needed.
include/xrpl/basics/Number.h
Outdated
| // * 9223372036854775808 | ||
| // * 9223372036854775809 | ||
| // They both end up < min, but with a leftover. If they round up, everything | ||
| // will be fine. If they don't, well need to bring them up into range. |
Copilot
AI
Feb 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in comment: 'well need' should be 'we'll need'.
| // will be fine. If they don't, well need to bring them up into range. | |
| // will be fine. If they don't, we'll need to bring them up into range. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
High Level Overview of Change
This PR, if merged, will change the large mantissa range from [10^18, 10^19-1] to [2^63/10+1, 2^63-1]. This allows the
Numberclass member variables to change back to a signed int64 mantissa and int exponent as they were before 3.1.0. This removes the boolean sign flag, and will thus reduce the memory footprint of allNumbers.This is a pure refactoring. No amendment is required.
Context of Change
Type of Change