Skip to content

HumanReadable: respect zero value input#46

Merged
pdorschner merged 2 commits into
masterfrom
bug/respect_zero_value
Mar 14, 2022
Merged

HumanReadable: respect zero value input#46
pdorschner merged 2 commits into
masterfrom
bug/respect_zero_value

Conversation

@pdorschner
Copy link
Copy Markdown

If a zero value input is parsed by HumanReadable, it should return always "0MB" and not a panic

Copy link
Copy Markdown

@tbauriedel tbauriedel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@RincewindsHat Second review and merge if ok please

Comment thread convert/bytes_common.go Outdated
//
func humanReadable(b uint64, units []string, base float64) (float64, string) {
if b == 0 {
return 0, "MB"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for nitpicking, but why not B instead of MB? Small efficiency improvement at not cost and no doubt about rounding errors.

@pdorschner pdorschner merged commit 56d6449 into master Mar 14, 2022
@pdorschner pdorschner deleted the bug/respect_zero_value branch March 14, 2022 12:51
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

Successfully merging this pull request may close these issues.

3 participants