diff options
author | Christopher Speller <crspeller@gmail.com> | 2018-05-18 07:32:31 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-18 07:32:31 -0700 |
commit | d5e1f7e2982c2fcc888ccac550b34095efbee217 (patch) | |
tree | d8cfe7e3f47537cce92b26a1b32b9081f0bd7993 /vendor/github.com/dustin/go-humanize/si.go | |
parent | d3ead7dc8535f8fa5b175686cc1f7669c8b1648b (diff) | |
download | chat-d5e1f7e2982c2fcc888ccac550b34095efbee217.tar.gz chat-d5e1f7e2982c2fcc888ccac550b34095efbee217.tar.bz2 chat-d5e1f7e2982c2fcc888ccac550b34095efbee217.zip |
Upgrading server dependency. (#8807)
Diffstat (limited to 'vendor/github.com/dustin/go-humanize/si.go')
-rw-r--r-- | vendor/github.com/dustin/go-humanize/si.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/vendor/github.com/dustin/go-humanize/si.go b/vendor/github.com/dustin/go-humanize/si.go index b24e48169..ae659e0e4 100644 --- a/vendor/github.com/dustin/go-humanize/si.go +++ b/vendor/github.com/dustin/go-humanize/si.go @@ -93,6 +93,16 @@ func SI(input float64, unit string) string { return Ftoa(value) + " " + prefix + unit } +// SIWithDigits works like SI but limits the resulting string to the +// given number of decimal places. +// +// e.g. SIWithDigits(1000000, 0, "B") -> 1 MB +// e.g. SIWithDigits(2.2345e-12, 2, "F") -> 2.23 pF +func SIWithDigits(input float64, decimals int, unit string) string { + value, prefix := ComputeSI(input) + return FtoaWithDigits(value, decimals) + " " + prefix + unit +} + var errInvalid = errors.New("invalid input") // ParseSI parses an SI string back into the number and unit. |