Is there a way to trim trailing 0s like the following? ```go s := d.String() if strings.Contains(s, ".") { s = strings.TrimRight(strings.TrimRight(s, "0"), ".") } ``` Is there a way to format a number with a given number of digits after the "." - something easier than this ```go str := fmt.Sprintf("%f", d) i := strings.Index(strings.TrimLeft(str, "-"), ".") if i < 0 { i = len(str) } r := p.Round(i + int(precision)) format := "%." + strconv.Itoa(int(precision)) + "f%%" return fmt.Sprintf(format, r) ```
Activity
bojanz commentedon May 15, 2020
Maybe you could copy some code from my formatter: https://github.com/bojanz/currency/blob/master/formatter.go
zeitlinger commentedon May 15, 2020
I'm afraid I don't understand it.
What I'm trying to say:
bojanz commentedon May 15, 2020
Apologies, I read your issue in a hurry and thought you were looking for a better formatting helper.
ericlagergren commentedon May 16, 2020
Just for string formatting? You can use the width verbs. Quantize does what you want too, but modifies the receiver.
zeitlinger commentedon May 18, 2020
ah, this is for the second use case - and works sometimes, but not always
lotodore commentedon Sep 28, 2022
@zeitlinger Call
Quantizetwice as a workaround, this will lead to 100.00 (and also works if precision is 0)Looking at the date of this issue... Is this library still supported, or "kind of archived"?
ericlagergren commentedon Oct 6, 2022
@lotodore I just haven't had a lot of time to work on it lately. But I will always make time to review and accept PRs.