docker / go-units

Parse and print size and time units in human-readable format
https://godoc.org/github.com/docker/go-units
Apache License 2.0
218 stars 38 forks source link

HumanSizeWithPrecision uses scientific notation in some invalid cases #44

Open kmirzavaziri opened 10 months ago

kmirzavaziri commented 10 months ago

Let's keep it short, such a test will fail:

assertEquals(t, "1GB", HumanSizeWithPrecision(999.6*MB, 3))

With the following message:

Expected '1GB' but got '1e+03MB'

The case holds in the following scenarios:

However, it works fine with precision 4 or higher.

kmirzavaziri commented 10 months ago

I am willing to fix this issue as a new person to open source contribution.