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

Fix ByteSize implementation in regards to IEC specification #1413

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

CollinAlpert
Copy link
Contributor

This PR is targeted for the v3 release, since it contains a breaking change in how the ByteSize calculates sizes.

Until now, one kilobyte is considered to be 1024 bytes, which is incorrect. The code Console.WriteLine(ByteSize.FromMegabytes(1).Bytes); prints 1048576 instead of 1000000 which was initially very surprising to me. I have had countless discussions over this surprising behavior with my teammates.

This PR fixes the calculation and adds methods to aid in calculating binary instead of decimal powers.

# Conflicts:
#	src/Humanizer/Localisation/DataUnit.cs
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.

1 participant