Repository navigation
A rational writes its decimal out again in a precision other than the one it kept - #1869
Merged
Rafael-SOWNet merged 3 commits intoOct 13, 2026
Conversation
… one it kept Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
…ts-decimal-out-in-the-precision-asked
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
Rafael-SOWNet
deleted the
a-rational-writes-its-decimal-out-in-the-precision-asked
branch
October 13, 2026 07:26
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1868.
Rational.EDecimalwas written out once, in the precision current the first time it was read, and kept from then on. Under a higherDecimalPrecisionContextthe rational still answered about a hundred digits, and so did every value computed from it. The integrator checks its answers at the default precision, so every rational in an antiderivative was affected: differentiating a right answer back at 300 or 2,000 digits left the same1e-102residual at both precisions. mpmath agrees with the answer to1e-322.The cache now holds the context it was written in and is written again under any other context. It is keyed by context instance, as the library's constant cache is. The holder is a struct equal to every other, like the caches on
Entity, so two equal rationals stay equal whichever one has been written out.Rational.Create(128, 12167).EDecimalread at the default precision, then under 300 digitssqrt(46) * 128/12167under 300 digits, with that rational4.7e-1014.1e-1012.5.0 wrote the decimal out when the rational was made, and master when it was first read; both kept it.
The new test in
HighPrecisionFunctionsTest, next to the same test fore(#1367), fails on master and passes here.Rubi corpus (pocket of all of 1.2.1.5, plus every family): identical on both arms, 0 moves and 0 wrong, as a precision fix should be. The allocation gate passed. The suite passed: 15,303 passed, 0 failed. Master 7ca5b88 is merged in, and the build passes for every target framework.
🤖 Generated with Claude Code
https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura