Commit Graph

108 Commits

Author SHA1 Message Date
Ed Hennis
f0d7dd0117 Merge branch 'ximinez/number-round-maxrep-down' into ximinez/number-round-maxrep 2026-06-25 19:12:17 -04:00
Ed Hennis
2a5b1b4e17 Review feedback from @gregtatcam, plus a few extras
- Rename MantissaRange::Get to MantissaRange::Access. The name doesn't
  really matter, but since the intent of the class is to control access
  to one function, this works.
- Exclude the MantissaScale enum from linting for
  readability-enum-initial-value. clang-tidy was complaining that
  "error: initial values in enum 'xrpl::MantissaRange::MantissaScale'
  are not consistent, consider explicit initialization of all, none or
  only the first enumerator", but I don't care. I just need Large to
  match the last value.
- Add a static_assert in setCurrentTransactionRules, so that if another
  MantissaScale is added (and Large is properly updated), the engineer
  won't forget to add a case for it there.
2026-06-25 19:02:53 -04:00
Ed Hennis
ba44e98e0e Merge branch 'ximinez/number-round-maxrep-down' into ximinez/number-round-maxrep 2026-06-25 15:33:12 -04:00
Ed Hennis
4ff398ba2d Address AI review feedback
- Mostly just clarifying comments and reorganizing functions.
2026-06-25 15:31:51 -04:00
Ed Hennis
cc4c06cf86 Address AI review feedback: mantissa assertion, test resiliency
- Move code around and add comments in `bringIntoRange` to make it
  clearer that mantissas should not be 0, but fall back gracefully in
  non-debug builds if they are.
- Make a test that checks for Large330 future-proof if more scales are
  added later.
2026-06-25 14:26:59 -04:00
Ed Hennis
6906f47349 Apply suggestions from AI code review: typos
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-06-25 14:25:32 -04:00
Ed Hennis
08736639c5 Restore an incorrectly removed const 2026-06-22 11:33:41 -04:00
Ed Hennis
7cb224e50f Update some comments, and const correctness 2026-06-18 20:59:20 -04:00
Ed Hennis
4124a1dd2d Revert "Remove changes to Number.cpp"
This reverts commit 8250aa2375.
2026-06-18 20:16:39 -04:00
Ed Hennis
8250aa2375 Remove changes to Number.cpp
- Show that old behavior is not affected, and that the new tests fail
  without them.
2026-06-18 20:15:19 -04:00
Ed Hennis
da396070ce Address review feedback from @TimothyBanks and @gregtatcam
- Remove unnecessary if constexpr check
- Update scaling static_assert
- Remove unnecessary rounding logic from Number::Guard::doRound()
- Handle fractional rounding between kMaxRep and kMaxRepUp
2026-06-18 17:57:21 -04:00
Ed Hennis
6179b054c9 Merge remote-tracking branch 'XRPLF/ximinez/number-round-maxrep-down' into ximinez/number-round-maxrep
* XRPLF/ximinez/number-round-maxrep-down:
  clang-tidy: Remove unused header
2026-06-18 13:18:07 -04:00
Ed Hennis
d373cb5db8 clang-tidy: Remove unused header 2026-06-18 13:16:16 -04:00
Ed Hennis
39d85076c4 Merge branch 'ximinez/number-round-maxrep-down' into ximinez/number-round-maxrep 2026-06-17 21:50:55 -04:00
Ed Hennis
6504042b8d Review feedback from @TimothyBanks and @gregtatcam
- Get rid of MantissaRange::getRanges() function. Rewrite
  getMantissaScale to use all constexpr values.
- In Number::Guard::round(), document the "intentional" shadowing of
  "mode", and simplify one of the checks. Add an assert.
2026-06-17 21:45:56 -04:00
Ed Hennis
51781c4cae Merge remote-tracking branch 'XRPLF/ximinez/number-round-maxrep-down' into ximinez/number-round-maxrep
* XRPLF/ximinez/number-round-maxrep-down:
  Clean up some comments, coverage exclusions, and an assert
2026-06-15 15:01:47 -04:00
Ed Hennis
a8f4d790bd Clean up some comments, coverage exclusions, and an assert 2026-06-15 14:05:44 -04:00
Ed Hennis
22a7f5bb49 Fix assertion typo src/libxrpl/basics/Number.cpp
Co-authored-by: xrplf-ai-reviewer[bot] <266832837+xrplf-ai-reviewer[bot]@users.noreply.github.com>
2026-06-12 19:44:08 -04:00
Ed Hennis
a63bab2a5e Cleanups: Comments, variable names, one test case
- "ToNearest and Downward behavior Small" test case
2026-06-12 19:38:07 -04:00
Ed Hennis
305977058b Merge remote-tracking branch 'XRPLF/ximinez/number-round-maxrep-down' into ximinez/number-round-maxrep
* XRPLF/ximinez/number-round-maxrep-down:
  Apply suggestions from AI code review
2026-06-12 19:08:04 -04:00
Ed Hennis
b30a70bbf8 Apply suggestions from AI code review
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-06-12 18:44:00 -04:00
Ed Hennis
1ef0c5ab44 Merge branch 'ximinez/number-round-maxrep-down' into ximinez/number-round-maxrep 2026-06-11 23:02:58 -04:00
Ed Hennis
463fb88cd8 Apply suggestions from AI code review
Co-authored-by: xrplf-ai-reviewer[bot] <266832837+xrplf-ai-reviewer[bot]@users.noreply.github.com>
2026-06-11 23:02:47 -04:00
Ed Hennis
353b3ae07d fixup! AI: Remove extranenous enum copy 2026-06-11 23:00:08 -04:00
Ed Hennis
b2790e2f50 AI: Remove extranenous enum copy
Co-authored-by: xrplf-ai-reviewer[bot] <266832837+xrplf-ai-reviewer[bot]@users.noreply.github.com>
2026-06-11 22:57:31 -04:00
Ed Hennis
308e00f590 Merge commit 'b087545' into ximinez/number-round-maxrep
* commit 'b087545':
  Number improvements
  test: Add more Number edge case tests, showing failures
2026-06-11 22:48:22 -04:00
Ed Hennis
5703ca527f Number improvements
- Expand documentation.
- Refactor Number::Guard::round() to simplify.
- Set the Guard sign correctly in += for numbers with the same exponent.
  - Only really relevant if both values are negative.
- In +=, when needed, expand one mantissa to a size large enough to have
  a few extra digits, which can be used to determine rounding.
  - If the exponents are still different, trim the other mantissa as
    before until the exponents match.
  - For subtraction (where the values' signs are different), pop digits
    out of the Guard as necessary, but go far enough to have a few extra
    digits again for rounding later.
  - Finally, don't discard any "leftover" digits in the Guard when
    normalizing, to avoid the 0.5....nnn problem.
2026-06-11 19:38:21 -04:00
Ed Hennis
5c62c15ad8 Future proofing: Rename Large and Enabled to Large330 and Enabled330
- If more fixes need to be made in the future, they can be added after,
  instead of needing to do the "rename dance", I had to do with this PR.
2026-06-11 19:38:20 -04:00
Ed Hennis
772e0c30f7 clang-tidy: rename MantissaScale enums from "3_2_0" to "320" 2026-06-11 19:38:20 -04:00
Ed Hennis
182ca1c12f Clean up the "New" names 2026-06-11 19:38:20 -04:00
Ed Hennis
2e97056b40 Update to use a new amendment, since this PR will not be part of 3.2.0
- This requires creating yet another MantissaScale, and CuspRoundingFix
  option.
2026-06-11 19:38:03 -04:00
Ed Hennis
693e9015ab clang-tidy: Guard public member variable names; Missing include 2026-06-11 19:38:01 -04:00
Ed Hennis
1162ccf7f4 Clean up tests 2026-06-11 19:37:57 -04:00
Ed Hennis
6cc45297d7 Fix formatting, add an assert 2026-06-11 19:37:56 -04:00
Ed Hennis
b263f442be Revert "Rollback Number class changes; show the fix works without side effects"
This reverts commit 8743be8eae.
2026-06-11 19:37:56 -04:00
Ed Hennis
7191574499 Rollback Number class changes; show the fix works without side effects 2026-06-11 19:37:56 -04:00
Ed Hennis
184f936362 Improve comment descriptions 2026-06-11 19:37:55 -04:00
Ed Hennis
64cb53629d Rework subtraction rounding (again) for more accuracy
- Go back to the old method of computing the mantissa, but when post
  processing, expand the mantissa to slightly larger than maxMantissa,
  then in doRoundDown, if the result is not exact, subtract one.
  Finally, let doNormalize figure out the rounding of the result.
2026-06-11 19:37:55 -04:00
Ed Hennis
8ca90e7d01 refactor: Construct Number::Guard from MantissaRange or relevant fields
- Simplifies the function signatures in Guard, because it doesn't need
  to have those values passed in constantly.
- Also simplifies some of the functions because they don't need to store
  values just to pass them to Guard functions.
2026-06-11 19:37:55 -04:00
Ed Hennis
48e0ca72b0 Improve accuracy of Number::operator+=
- Use more of the available range of the uint128 operands.
- Also refactor Number::Guard::round() to return an enum.
2026-06-11 19:37:54 -04:00
Ed Hennis
6d89fbef7a Experimental: Scale addition operands up to preserve accuracy 2026-06-11 19:37:54 -04:00
Ed Hennis
b087545755 Number improvements
- Expand documentation.
- Refactor Number::Guard::round() to simplify.
- Set the Guard sign correctly in += for numbers with the same exponent.
  - Only really relevant if both values are negative.
- In +=, when needed, expand one mantissa to a size large enough to have
  a few extra digits, which can be used to determine rounding.
  - If the exponents are still different, trim the other mantissa as
    before until the exponents match.
  - For subtraction (where the values' signs are different), pop digits
    out of the Guard as necessary, but go far enough to have a few extra
    digits again for rounding later.
  - Finally, don't discard any "leftover" digits in the Guard when
    normalizing, to avoid the 0.5....nnn problem.
2026-06-11 18:59:59 -04:00
Ed Hennis
e4dafa3171 Update names due to prior merge 2026-06-09 19:14:40 -04:00
Ed Hennis
1477747c37 Merge remote-tracking branch 'XRPLF/ximinez/number-round-maxrep-down' into ximinez/number-round-maxrep
* XRPLF/ximinez/number-round-maxrep-down:
  Also fix local 3_2_0 variable names
  Future proofing: Rename Large and Enabled to Large330 and Enabled330
  clang-tidy: rename MantissaScale enums from "3_2_0" to "320"
2026-06-09 19:09:39 -04:00
Ed Hennis
48d1c70b6c Future proofing: Rename Large and Enabled to Large330 and Enabled330
- If more fixes need to be made in the future, they can be added after,
  instead of needing to do the "rename dance", I had to do with this PR.
2026-06-09 18:44:46 -04:00
Ed Hennis
66ff72f56d clang-tidy: rename MantissaScale enums from "3_2_0" to "320" 2026-06-09 18:38:03 -04:00
Ed Hennis
4139ebbe6b Fix issues introduced by prior merge, and new MantissaRange 2026-06-09 18:31:59 -04:00
Ed Hennis
9924b6ce65 Merge remote-tracking branch 'XRPLF/ximinez/number-round-maxrep-down' into ximinez/number-round-maxrep
* XRPLF/ximinez/number-round-maxrep-down:
  Clean up the "New" names
  Update to use a new amendment, since this PR will not be part of 3.2.0
  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)
  ci: Use new packaging images and don't cancel develop builds (7417)
  ci: [DEPENDABOT] bump codecov/codecov-action from 6.0.1 to 7.0.0 (7426)
2026-06-09 18:08:04 -04:00
Ed Hennis
63f1a40b77 Clean up the "New" names 2026-06-09 17:06:27 -04:00
Ed Hennis
d9c63cb9bc Update to use a new amendment, since this PR will not be part of 3.2.0
- This requires creating yet another MantissaScale, and CuspRoundingFix
  option.
2026-06-09 16:44:13 -04:00