Skip to content

refactor: Use a range of 2^63/10+1 to 2^63-1 for large Number mantissas#6275

Draft
ximinez wants to merge 164 commits into
developfrom
ximinez/number-maxint-range
Draft

refactor: Use a range of 2^63/10+1 to 2^63-1 for large Number mantissas#6275
ximinez wants to merge 164 commits into
developfrom
ximinez/number-maxint-range

Conversation

@ximinez

@ximinez ximinez commented Jan 23, 2026

Copy link
Copy Markdown
Collaborator

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 Number class 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 all Numbers.

This is a pure refactoring. No amendment is required.

Context of Change

Type of Change

  • Refactor (non-breaking change that only restructures code)
  • Tests (you added tests for code that already exists, or your new feature included in this PR)

@ximinez ximinez changed the title Revert "Bugfix: Adds graceful peer disconnection (#5669)" (#5855) DRAFT: Can I use an int64 range? Jan 23, 2026
@ximinez ximinez changed the base branch from develop to release-3.1 January 23, 2026 20:57
@ximinez ximinez force-pushed the ximinez/number-maxint-range branch from 3094798 to c01bfb2 Compare January 23, 2026 21:01
@ximinez ximinez added the DraftRunCI Normally CI does not run on draft PRs. This opts in. label Jan 26, 2026
@ximinez ximinez force-pushed the ximinez/number-maxint-range branch from 3934fdb to b0d8b61 Compare January 27, 2026 02:12
@ximinez ximinez added DraftRunCI Normally CI does not run on draft PRs. This opts in. and removed DraftRunCI Normally CI does not run on draft PRs. This opts in. labels Jan 27, 2026
@codecov

codecov Bot commented Jan 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.38462% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.3%. Comparing base (7ba1d76) to head (82ca28f).

Files with missing lines Patch % Lines
include/xrpl/basics/Number.h 86.0% 8 Missing ⚠️
src/libxrpl/basics/Number.cpp 99.3% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           develop   #6275     +/-   ##
=========================================
- Coverage     82.3%   82.3%   -0.0%     
=========================================
  Files         1024    1024             
  Lines        78455   78510     +55     
  Branches      8978    8981      +3     
=========================================
+ Hits         64574   64615     +41     
- Misses       13872   13886     +14     
  Partials         9       9             
Files with missing lines Coverage Δ
include/xrpl/protocol/Protocol.h 100.0% <ø> (ø)
include/xrpl/protocol/STAmount.h 94.6% <100.0%> (+<0.1%) ⬆️
include/xrpl/protocol/SystemParameters.h 100.0% <ø> (ø)
src/libxrpl/basics/Number.cpp 99.0% <99.3%> (+0.1%) ⬆️
include/xrpl/basics/Number.h 94.3% <86.0%> (-4.1%) ⬇️

... and 6 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ximinez ximinez force-pushed the ximinez/number-maxint-range branch from 7275749 to 6fcb32e Compare January 27, 2026 23:22
@ximinez ximinez changed the base branch from release-3.1 to ximinez/staging-3.1 January 27, 2026 23:55
- 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.
- Simplify shiftExponent().
- Clean up to_string() to prevent integers from including "e0".
- Fix root() and root2() computations by ensuring the mantissas have
  a consistent length.
- Steal changes from @pratik's #6150 to avoid UB
…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)
@ximinez ximinez changed the base branch from ximinez/staging-3.1 to tapanito/lending-fix-amendment February 5, 2026 02:10
@ximinez ximinez force-pushed the ximinez/number-maxint-range branch from 9457b82 to 154bb65 Compare February 5, 2026 02:11
@ximinez ximinez changed the title DRAFT: Can I use an int64 range? Use a range of 2^63/10+1 to 2^63-1 for large mantissas Feb 5, 2026
@ximinez ximinez marked this pull request as ready for review February 5, 2026 17:27
@ximinez ximinez requested a review from a team February 5, 2026 17:27
@ximinez ximinez marked this pull request as draft February 5, 2026 17:27
@ximinez ximinez changed the base branch from tapanito/lending-fix-amendment to develop February 5, 2026 17:29
…nt-range

* XRPLF/develop:
  release: Bump version to 3.2.0-rc2 (7348)
  refactor: Enable support for `fixCleanup3_2_0` amendment (7347)
  release: Bump version to 3.2.0-rc1 (7335)
  fix: Fix a rounding error at the `Number::maxRep` cusp (7051)
@github-actions

Copy link
Copy Markdown

All conflicts have been resolved. Assigned reviewers can now start or resume their review.

ximinez and others added 8 commits May 27, 2026 17:00
- Add missing headers.
- Improve code coverage exclusions.
- Clean up several variable names.
- Improve explanatory comments.
- Remove the switch statement from MantissaRange::getMin. Change it to
  a straight power of ten lookup.
- Demonstrates the incorrect "before" behavior
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
- Downward with a negative result, and ToNearest with a remainder
  slightly larger than 0.5.
@github-actions

Copy link
Copy Markdown

This PR has conflicts, please resolve them in order for the PR to be reviewed.

ximinez added 4 commits June 1, 2026 13:16
… into ximinez/number-maxint-range

* XRPLF/ximinez/number-division-accuracy:
  CI feedback: Add test cases covering other rounding modes
  Apply suggestions from code review
  Accept AI suggestion
  Update the testUpwardRoundsDown test to run under all scales
  Review feedback from Tapanito and AI
  Skip clang-tidy false positive: misc-include-cleaner
  ci: Run PR title and description checks on staging and release branches (7331)
  style: Run shfmt on workflows, actions and markdown bash code (7333)
  Remove TMax entirely from normalizeToRange; check type matching directly
  Tweak how the denominator is handled in division
  Minor fixes: missing include, variable init, typo
  Test optimization: Number_test::pow10
  Significant rewrite
  Use the local range instead of calling a function
  Make Number::operator/= significantly more accurate
* commit '1599c1a672':
  refactor: Revert "perf: Remove unnecessary caches (5439)" (7359)
  fix: Add zero domainID check for permissionedDomain (7362)
* commit '47365f4220':
  fix: Improve upward rounding edge cases for Number::operator/= (7328)
…nt-range

* XRPLF/develop:
  ci: Check binaries separately from building them (7355)
  ci: [DEPENDABOT] bump eps1lon/actions-label-merge-conflict from 3.0.3 to 3.1.0 (7375)
  refactor: Use `STLedgerEntry` type aliases instead of `std::shared_ptr` (7282)
  fix: Adjust xrpld systemd service and update timer (7374)
  release: Bump version to 3.2.0-rc3 (7371)
  fix: Pin overpayment principal reduction to exact on-grid value (7360)
@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown

All conflicts have been resolved. Assigned reviewers can now start or resume their review.

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

This PR has conflicts, please resolve them in order for the PR to be reviewed.

…nt-range

* XRPLF/develop: (37 commits)
  test: Add null check unit test for `Oracle::aggregatePrice` (7306)
  ci: Patch conan recipe for Nix to be able to use on macOS (7532)
  ci: Run sanitizers on release builds too (7527)
  fix: Correct hybrid offer deletion on credential expiry (6843)
  ci: Make sanitizer flags lists in the profile, not a string (7449)
  ci: Make configurations launch on certain event types (7447)
  fix: Add [[maybe_unused]] to fix320Enabled for assert=OFF builds (7446)
  ci: Add `gh` and `file` to nix packages (7444)
  fix: Disable transaction invariants (7409)
  perf: Dispatch "hasInvalidAmount()" on type tag instead of dynamic_cast (7402)
  refactor: Retire fixUniversalNumber amendment (5962)
  test: Do not create data directory for memory databases (7323)
  ci: Launch upload-conan-deps on profile change (7442)
  fix: Fix Number comparison operator (7406)
  feat: Use C++ 23 standard (7431)
  refactor: Introduce XRPL_ASSERT_IF for amendment-gated assertions (7378)
  refactor: Change config section and key string literals into constants (7095)
  refactor: Use `std::move` and `std::string_view` where possible (7424)
  refactor: Use const function arguments where possible (7423)
  ci: Use XRPLF/actions build-multiarch-image workflow (7428)
  ...
@github-actions

Copy link
Copy Markdown

All conflicts have been resolved. Assigned reviewers can now start or resume their review.

- Instead of completely removing the code, it is wrapped in an `if
  constexpr` sign check. That way, it's future proof in case the type of
  mantissa_ ever changes again.
- Ironically, this partially reverts PR 7406.
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

This PR has conflicts, please resolve them in order for the PR to be reviewed.

…nt-range

* XRPLF/develop: (80 commits)
  refactor: Retire DisallowIncomingV1 fix (7364)
  build: Add verify-headers target to cleanup headers (7670)
  refactor: Retire InnerObjTemplate fix (7368)
  fix: Disable AMM creation with Vault shares (7666)
  test: Add tests for TMProofPathResponse and TMReplayDeltaResponse invalid hash/key sizes (7593)
  ci: [DEPENDABOT] bump actions/setup-python from 6.2.0 to 6.3.0 (7657)
  build: Don't reuse binaries between different C++ versions (7681)
  chore: Update pre-commit hooks && actions (7686)
  feat: Add an invariant to ensure object deletion also deletes its pseudo-account (7445)
  feat: Add Batch (XLS-56) V1_1 (6446)
  feat: Introduce lending 1.1 amendment and add `MemoData` field to `VaultDelete` transaction (6324)
  chore: Use std::ranges where possible (7634)
  ci: Use macOS 26 Tahoe with apple-clang 21 (7601)
  build: Mark sec256k1 and mpt-crypto as transitive headers (7658)
  chore: Add a script to nicely format clang-tidy output (7650)
  chore: Enable most bugprone checks (7643)
  feat: Confidential Transfer for MPT (5860)
  fix: Use trustline balance direction to validate IOU PaymentMint/PaymentBurn (7584)
  fix: Unify freeze checks for pseudo-account deposit/withdraw (7382)
  fix: Block delegate tx from being queued (7640)
  ...
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

All conflicts have been resolved. Assigned reviewers can now start or resume their review.

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

This PR has conflicts, please resolve them in order for the PR to be reviewed.

ximinez added 2 commits July 2, 2026 19:48
…nt-range

* XRPLF/develop:
  chore: Enable modernize-use-auto (7707)
  build: Add protobuf dependencies to Nix (7706)
  feat: Enable ConfidentialTransfer and BatchV1_1 (7698)
  chore: Enable modernize-unary-static-assert (7705)
  chore: Make clang-tidy happy on macOS (7701)
  chore: Improve pre-commit hooks (7702)
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

All conflicts have been resolved. Assigned reviewers can now start or resume their review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DraftRunCI Normally CI does not run on draft PRs. This opts in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants