Repository navigation
A complex number prints the number it holds, whatever the downcasting setting at printing - #1611
Merged
Merged
Conversation
… setting at printing Printing a complex number with a negative imaginary part negated that part, to print a minus sign before its magnitude. Negating makes a new number, and a new number is downcast under the setting in force when it is made. A number made with downcasting off, and printed once it was back on, printed as another number: 1 - 0.333...i, the decimal to forty digits, as 1 - 1/3i, a fraction without the product sign it needs, which reads back as 1 + i/3; and the imaginary part of erfc(16 - 0.5i), -9.49e-114, as 0. Latexize did the same. Such numbers come out of the library's own downcasting-off scopes as well: the factorial's evaluation and the integrator's checks open one. Both printers negate with the downcasting off, so the negation is the same number with its sign changed. Under one setting throughout nothing prints differently: Real.Create rounds nothing in either mode, and what it snaps to an integer or a small rational it snaps the same way at either sign. StringizeRoundTripTest gains three numbers made with downcasting off. Each reads back as itself from what Stringize prints, and Latexize prints its imaginary part's magnitude. All three fail without the change. Closes #1610. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rafael-SOWNet
added a commit
that referenced
this pull request
Oct 9, 2026
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
Rafael-SOWNet
added a commit
that referenced
this pull request
Oct 9, 2026
* Breaking-changes entries for #1828 to #1832 and #1374 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura * And for #1368, #1611 and #1517, each measured on 2.5.0 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura * And for #1289, #1312, #1315, #1377, #1380 and #1371, each measured on 2.5.0 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
Printing a complex number with a negative imaginary part negated that part, to print the minus sign before its magnitude. Negating makes a new number, and a new number is downcast under the setting in force when it is made. So a number made with downcasting off printed as another number once downcasting was back on:
1 - 0.3333333333333333333333333333333333333333i1 - 1/3i1 + i/32 - 0.5000000000000000000000000000001i2 - 1/2i2 + i/2erfc(16 - 0.5i), imaginary part-9.4899…E-114-2.8337…E-113 - 0iThe fraction also came out without the product sign it needs beside
i, because that sign was decided from the number before the negation.Latexizehas the same fault. The library returns such numbers itself as well:Number.Factorialevaluates a complex argument with the downcasting off and returns what it made there.Both printers now negate with the downcasting off, so the negation is the same number with its sign changed. Under a single setting throughout, nothing prints differently.
Real.Createrounds nothing in either mode, and whatever it snaps to an integer or a small rational it snaps the same way at either sign.Measured
StringizeRoundTripTestgains the three numbers above, each made with downcasting off. Each reads back as itself from whatStringizeprints, andLatexizeprints its imaginary part's magnitude. All three fail without the change, with the readings in the table.Closes #1610.
🤖 Generated with Claude Code