feat(#4752): add reusable tt converters for sprintf#5272
Merged
yegor256 merged 4 commits intoJun 29, 2026
Conversation
Write an ASCII code (0-255) as its single byte, the inverse of `as-ascii`. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Write a number as signed decimal digits, truncating its fraction toward zero. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Write bytes as uppercase hexadecimal pairs joined by a hyphen. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Write a number as fixed-point decimal with a chosen number of fraction digits, rounding to the nearest unit in the last place. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
🚀 Performance AnalysisAll benchmarks are within the acceptable range. No critical degradation detected (threshold is 100%). Please refer to the detailed report for more information. Click to see the detailed report
✅ Performance gain: |
asmirnov-backend
marked this pull request as ready for review
June 27, 2026 16:31
Contributor
Author
|
@yegor256, could you please take a look |
|
|
@asmirnov-backend Thanks for the contribution! You've earned +12 points for this: +16 as a basis; -4 for too many hits-of-code (266 >= 100). Please, keep them coming. Your running score is +144; don't forget to check your Zerocracy account too). |
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.



Part of #4752. Prerequisite for #5271.
Adds four small, independently tested
ttobjects that render numbers and bytes as text:as-char— ASCII code (0-255) → single byte, the inverse ofas-asciias-decimal— number → signed decimal digits, truncating toward zeroas-hex— bytes → uppercase hexadecimal pairs joined by a hyphenas-fixed— number → fixed-point decimal with a chosen number of fraction digits, roundedWhy
Without these objects,
tt.sprintf(#5271) carries a lot of internal methods —dec,digits,one-digit,flt,positive,rec-pad,hex,rec-hex,hex-digit— and becomes complicated to read. Extracting them into focused, reusable objects (mirroring the existingas-asciiandis-digit) keeps each concern small and letssprintfcompose them instead of inlining everything.Once this is merged, #5271 is rebased to drop the inline formatters and use these objects directly.