Skip to content

Fix ByteSize implementation in regards to IEC specification#1413

Open
CollinAlpert wants to merge 5 commits intoHumanizr:mainfrom
CollinAlpert:byte-math
Open

Fix ByteSize implementation in regards to IEC specification#1413
CollinAlpert wants to merge 5 commits intoHumanizr:mainfrom
CollinAlpert:byte-math

Conversation

@CollinAlpert
Copy link
Copy Markdown
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