Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to adjust precision of Commaf #72

Open
Light-Wizzard opened this issue Jul 13, 2018 · 1 comment
Open

How to adjust precision of Commaf #72

Light-Wizzard opened this issue Jul 13, 2018 · 1 comment

Comments

@Light-Wizzard
Copy link

Light-Wizzard commented Jul 13, 2018

humanize.Commaf(float64(1.1234567890), 2)
strconv.FormatFloat has a precision, just add and int like:
since you can not overload you could copy the func and rename it Commafp
that way it does not break.
Also noted that this is not localized; not that hard to localize the comma and period.

func Commafp(v float64, prec int) string {
...
parts := strings.Split(strconv.FormatFloat(v, 'f', prec, 64), ".")

Update: This does the same thing: CommafWithDigits

@WeiChieh-Chen
Copy link

so...seems like should be closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants