refactor: rename to FormatFloatComma, document rounding vs truncation - #148
Open
walle250ai wants to merge 3 commits into
Open
refactor: rename to FormatFloatComma, document rounding vs truncation#148walle250ai wants to merge 3 commits into
walle250ai wants to merge 3 commits into
Conversation
Adds CommafWithPrecision(num float64, digits int) string that formats a float with thousands-separator commas and a fixed decimal precision. FormatFloat already exists in number.go with a different signature so a new name is used. Delegates to strconv.FormatFloat for rounding, then applies the same comma-insertion logic as Commaf/CommafWithDigits. Tests cover positive, negative, zero, digits=0/2/4. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…CommafWithDigits Establishes a clear naming axis: FormatFloat (no separators, format-string) vs FormatFloatComma (thousands separators, fixed precision). Adds godoc note that FormatFloatComma rounds via strconv.FormatFloat while CommafWithDigits truncates. Test added to make the rounding/truncation contrast explicit. Co-Authored-By: Claude Sonnet 4.6 <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.
Summary
Follow-up to #147. Renames
CommafWithPrecision→FormatFloatCommaand adds explicit documentation distinguishing it fromCommafWithDigits.Changes
Naming rationale:
FormatFloatnumber.goCommaf/CommafWithDigitscommaf.goFormatFloatCommacomma.gostrconv.FormatFloat(half-to-even)Godoc addition:
New test case illustrating the difference:
All existing tests continue to pass.
🤖 Generated with Claude Code