- In numberFromJson(), if the result is 0, only the mantissa has to
match, because there are many valid ways to represent 0.
- Update several broken tests that I missed earlier.
- Change the parsing in numberFromJson so that if the resulting Number
is not the same as the parsed NumberParts, then throw, because
unexpected rounding occurred
- Add modified suggested test cases, and modify some existing ones,
which test this behavior.
- 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.
- 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.
- 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.
* XRPLF/ximinez/number-round-maxrep-down:
Change placeholder "fixNumberStuff" to "fixCleanup3_3_0"
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)
* commit '5703ca5': (23 commits)
Number improvements
test: Add more Number edge case tests, showing failures
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"
Clean up the "New" names
Update to use a new amendment, since this PR will not be part of 3.2.0
clang-tidy: Guard public member variable names; Missing include
Clean up tests
Reorganize the subtraction tests
Fix formatting, add an assert
Revert "Rollback Number class changes; show the fix works without side effects"
Rollback Number class changes; show the fix works without side effects
Include rounding in failed unit tests
Improve comment descriptions
Rework subtraction rounding (again) for more accuracy
refactor: Construct Number::Guard from MantissaRange or relevant fields
clang-tidy: template param names, const correctness, braces
Remove the kMaxRep+1 rounding tests
Improve accuracy of Number::operator+=
...
* XRPLF/develop:
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)
- 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.
- NumberAddDirectedSignWrong
- Addition of two negative numbers with the same exponent rounds
ToNearest in the wrong direction.
- Also include unit test cases with same exponent, and mixed signs.
- No rounding issues in any combination, because the exponent can't
change.
- NumberAddToNearestPicksFarther
- In scenarios where the two operands have different signs, and
significantly different exponents, you can end up in a situation
where the rounding looks like 0.5, which may round down to even, but
is actually 0.5....nnn, which should always round up, you get the
wrong result.
- 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.
- 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.
- 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.
- NumberAddDirectedSignWrong
- Addition of two negative numbers with the same exponent rounds
ToNearest in the wrong direction.
- Also include unit test cases with same exponent, and mixed signs.
- No rounding issues in any combination, because the exponent can't
change.
- NumberAddToNearestPicksFarther
- In scenarios where the two operands have different signs, and
significantly different exponents, you can end up in a situation
where the rounding looks like 0.5, which may round down to even, but
is actually 0.5....nnn, which should always round up, you get the
wrong result.
* 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"
* 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)
* XRPLF/develop:
fix: Fix Number comparison operator (7406)
feat: Use C++ 23 standard (7431)
refactor: Introduce XRPL_ASSERT_IF for amendment-gated assertions (7378)
* XRPLF/develop:
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)
* ximinez/number-round-maxrep-down:
Revert "Rollback Number class changes; show the fix works without side effects"
Rollback Number class changes; show the fix works without side effects
Include rounding in failed unit tests
Improve comment descriptions
Rework subtraction rounding (again) for more accuracy
build: Create single test binary xrpl_tests (7327)
ci: [DEPENDABOT] bump actions/checkout from 6.0.2 to 6.0.3 (7414)
ci: Refactor build-related nix / docker / workflows (7408)
refactor: Construct Number::Guard from MantissaRange or relevant fields
ci: Use multiple directories in dependabot config (7413)
ci: Update clang-tidy to nix-based v22 (7412)
clang-tidy: template param names, const correctness, braces
- 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.
- 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.
- Treat values in between kMaxRep (2^63-1) and kMaxRepUp (((kMaxRep
/ 10) + 1) * 10, which is the next multiple of 10 above kMaxRep) as if
those values were sequential, and values in between were "fractional".
- This results in values above the midpoint rounding up to kMaxRepUp,
and below the midpoint to kMaxRep when rounding to nearest. Other
rounding modes act along the same lines.
- Also refactor "Number::Guard::round()` to return an enum making it
clearer what's going on.
* 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)
fix: Improve upward rounding edge cases for Number::operator/= (7328)
refactor: Revert "perf: Remove unnecessary caches (5439)" (7359)
fix: Add zero domainID check for permissionedDomain (7362)
- 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.
- Simplify Number::operator/= to use more constexpr values, and fewer
variations.
- Most significantly, rounding up doesn't need more precision, it only
needs to know if there's a remainder after the current precision work
is done. Tracked similarly Guard::xbit_.
- Build a constexpr lookup array for powers of 10. Only a handful of
values are used, but since it's built at compile time, and constexpr,
unused values do not affect memory or performance.
- Predeclare type reference in Rules.h
- Remove an unneeded include in EscrowToken_test
- Number_test will format negative BigInts correctly (unused)
- Remove an inaccurate comment
- Order the checks so that large mantissa is only enabled if SAV or LP
are enabled. fixCleanup3_2_0 only enables the rounding fix.
- Fix tests, and don't exclude fixCleanup3_2_0 in AMM tests
- Also fix formatting
* XRPLF/develop:
release: Set version to 3.3.0-b0 (7280)
refactor: Rename static constants (7120)
refactor: Use `isFlag` where possible instead of bitwise math (7278)
ci: Update XRPLF/actions (7281)
- Some EscrowToken tests used a hard-coded list of amendments to
determine whether to expect large mantissa logic. That ignored the
effects of fixCleanup3_2_0, especially as applied to the previous fix
affecting preflight, preclaim, etc.
- Add a helper function, useRulesGuards, which will return the same
decision as createGuards and setCurrentRulesImpl. Use that helper
function in the relevant tests.
- Also remove an #include that clang-tidy was complaining about.
- Refactor the Guard decision in withTxnType into createGuards, which
lives in Rules.cpp. It is physically located near
setCurrentTransactionRules, and documented to explain that changes
need to be synchronized.
- Add helper function, doDropDigit, to wrap the common pattern:
push(mantissa % 10);
mantissa /= 10;
++exponent;
- Might have been helpful to catch this issue when developing.
2026-05-06 22:49:44 -04:00
9 changed files with 1872 additions and 530 deletions
// but minint's mantissa is > kMaxRep, and so rounds, and thus can't be parsed
expectParseThrows(minInt);
}
}
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.