Repository navigation
fix(print): BigInt/Ratio/BigDecimal print past std's 64-limb bound (CLJW-BIGINT-STR-PLACEHOLDER) - #84
Merged
Merged
Conversation
std's big-int `{f}` formatter renders through a 64-limb stack buffer
(about 1233 digits) and writes the literal "(BigInt)" past it, so
(str (reduce *' (range 1N 1000N))) answered "(BigInt)".
- runtime/numeric/decimal_text.zig: writeDecimal / decimalAlloc /
writeFraction, no width ceiling. Every BigInt, Ratio and BigDecimal
print path (str, pr-str, .toString, print, json, analyzer literal
round-trip, BigDecimal digit/plain renders) goes through it.
- rationalize of a BigDecimal computes 10^|scale| exactly instead of a
1040-byte digit-string round-trip, so it has no digit/scale ceiling.
- big_decimal/allocFromDecimalString sizes its digit scratch to the
mantissa (was a 512-digit cap), so bigdec reads any width.
- format %s of a BigInt/BigDecimal is .toString like clj: no N/M suffix.
Pinned by suites/bignum_print_width_test (3500!, 10887 digits) and the
clj-oracle corpus test/diff/clj_corpus/bignum_print_width.txt (18/18
matched against JVM clj).
Smell-audited: 2: fixed-buffer formatter ceiling swept across all print paths; two sibling width caps (bigdec parse, rationalize) removed in the same sweep
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.
std's big-int
{f}formatter renders through a 64-limb stack buffer(about 1233 digits) and writes the literal "(BigInt)" past it, so
(str (reduce *' (range 1N 1000N))) answered "(BigInt)".
writeFraction, no width ceiling. Every BigInt, Ratio and BigDecimal
print path (str, pr-str, .toString, print, json, analyzer literal
round-trip, BigDecimal digit/plain renders) goes through it.
1040-byte digit-string round-trip, so it has no digit/scale ceiling.
mantissa (was a 512-digit cap), so bigdec reads any width.
Pinned by suites/bignum_print_width_test (3500!, 10887 digits) and the
clj-oracle corpus test/diff/clj_corpus/bignum_print_width.txt (18/18
matched against JVM clj).