Humanizer icon indicating copy to clipboard operation
Humanizer copied to clipboard

Fix ByteSize implementation in regards to IEC specification

Open CollinAlpert opened this issue 1 year ago • 0 comments

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.

CollinAlpert avatar Feb 18 '24 15:02 CollinAlpert