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

HumanSizeWithPrecision uses scientific notation in some invalid cases #44

Open
kmirzavaziri opened this issue Jan 14, 2024 · 1 comment

Comments

@kmirzavaziri
Copy link

kmirzavaziri commented Jan 14, 2024

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:

  • any 999.5 <= x < 1000 for any unit including bytes, kB, MB, GB, etc. (with precision 1, 2, or 3)
  • any 99.5 <= x < 1000 for any unit including bytes, kB, MB, GB, etc. (with precision 1 or 2)
  • any 9.5 <= x < 1000 for any unit including bytes, kB, MB, GB, etc. (with precision 1)

However, it works fine with precision 4 or higher.

@kmirzavaziri
Copy link
Author

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

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

1 participant