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
Byte size to follow IEEE standard #657
base: main
Are you sure you want to change the base?
Byte size to follow IEEE standard #657
Conversation
…exception on null and empty values, just like other TryParse methods
Added tests & fixed the double comparison assertions Corrected the symbol for kibibytes to use a capital K
Thanks for the great contribution. This is a significant breaking change though, and like @omar mentioned here, while technically wrong, is what most people expect. Can I suggest that you keep the existing functionality as default behavior, to avoid breaking the behavior, and add a strategy to switch to IEEE standard through config? This is an example of a similar implementation. |
|
@clairernovotny If the conflicts were resolved, would this PR be accepted? |
IMO, the default should be decimal units (1 kB = 1,000 bytes). |
That is a fair point and I completely agree but there are folks who have taken dependency on this - changing the behaviour will break many apps. If we want to change the behaviour, we need to bump the major version. I still suggest we have a strategy in there that allows people to revert back to the old behaviour through config. Thoughts? |
Absolutely.
I have no issue with that. I just believe that the default should be decimal units. |
@MehdiK i think it would suffice to tell people to move to the new extensions methods. eg "if you want the old behavior change usages of Kilobytes to Kibibytes" |
They may still want it to show "kilobytes" and not "kibibytes" in certain cases:
|
Are If the code is |
@glen-84 That is correct and I think this should be the default anyway. If you want a KiB output, you can specify so in the format by passing "KiB" to the call. |
But what does this output? var maxFileSize = (10).Kibibytes();
maxFileSize.LargestWholeNumberSymbol; // ? I'd expect to see |
@glen-84 I agree this would be the expectation at first glance. However a more consistent approach would be not to think of kilobytes and kibibytes as separate units, but more of different representations of the actual unit (byte). The same amount of bytes can be expressed in KB as well as KiB. These are not different units. In your example, I personally would expect "KB" to be printed, since it is more common and many people don't even know what a kibibyte is. For those people who want to have "KiB" displayed, they can still request it. Also, the implementation would become quite bloated when trying to guess what the developer wants. Say, you write the following: |
If I read: (1024).Kibibytes().ToString(); I expect to see If the When adding two This is the way that I see it, but I'm curious as to what others think. |
Changed ByteSize to follow IEEE and IEC standards for byte sizes (kibi vs kilo, etc.) see #592