Support binary and decimal bytes (i.e. 1 kibi = 1024 b and 1 kb = 1000 b)#24
Support binary and decimal bytes (i.e. 1 kibi = 1024 b and 1 kb = 1000 b)#24
Conversation
|
Looking forward to when this gets merged |
|
I decided to make this v2 given the changes that went into. An alpha is up on NuGet https://www.nuget.org/packages/ByteSize/2.0.0-alpha1 |
README.md
Outdated
| `ByteSize` assumes `1 kilobyte` = `1024 bytes`. See [why here](http://omar.io/2017/01/16/when-technically-right-is-wrong-kilobytes.html). | ||
| `ByteSize` comes with 3 different ways to represent bytes: | ||
|
|
||
| - `DecimalByteSize` which assumes `1 kilobyte` = `1000 bytes` with 2 letter abbrevations `b`, `B`,`KB`, `MB`, `GB`, `TB`, `PB`. |
There was a problem hiding this comment.
I've started to use your alpha-version and faced with problem with naming KB for Decimal. It seems that for Decimal it should be 'kB' instead of 'KB'.
https://en.wikipedia.org/wiki/Kilobyte
https://en.wikipedia.org/wiki/Mega-
There was a problem hiding this comment.
It will be cool if you'll build version new alpha version before completing PR 😎
|
I observed the Have you ever worked with the I suggest keeping only one struct that can do all the desired jobs.
There are already some methods like these. If you want compatibility for those who refuse the standard, you can make a static switch that will change the behavior of If you don't like having multiple methods to get the string representation, then you can add an enum parameter or a renderer class. If you still don't like that, you can also create a new format that can be passed to the What do you think? |
|
I agree with @sandrock. Another comparison could be temperature. Temperature is a property of a substance. It can have a value, which is probably represented the most canonically as an average velocity of particles in that substance. But as we all know, the temperature also has many more common representations, i.e. Fahrenheit or Celsius. The temperature in this context is file size (or "content-length", or, more precisely, "data size"). The base representation is the number of bytes, or just "bytes". Kilobytes, kibibytes, megabytes, mebibytes, etc. are all alternative representations. It doesn't make much sense to have |
|
I appreciate the feedback in this thread. To give some context, I initially had a single struct to manage both decimal and binary values. I went down the route of using separate structs make it explicit what the value being represented. I also wanted to keep backwards compatibility and provide users a way to do it the "wrong" way which is what the Given that, I'm thinking of dropping support for the non standard representation and going with the only decimal (kilobyte) and binary (kibibyte) because this is the trend we're heading down based on the limited research I've done. So to summarize, alpha 2 of this will look like this:
Thanks again for taking the time to give your feedback. I'll get started on the changes above. In the meantime, let me know if you agree/disagree with the direction. |
# Conflicts: # .travis.yml # Makefile # global.json # src/ByteSizeLib.Tests/ByteSizeLib.Tests.csproj # src/ByteSizeLib/ByteSizeLib.csproj
|
I just pushed alpha 2 to NuGet. https://www.nuget.org/packages/ByteSize/2.0.0-alpha2 I realized that I don't have a good API setup for the I'm thinking |
# Conflicts: # README.md # src/ByteSizeLib.Tests/ParsingMethods.cs

Breaking Changes:
netstandard2.0.ByteSizefromByteSizeLib.ByteSizerenamed toNonStandardByteSizebut keeps same functionality.New Features:
DecimalByteSizeobject:1 KB = 1000 Bwith abbreivationsKB,MB, etc.BinaryByteSizeobject:1 KiB = 1024 Bwith abbreivationsKiB,MiB, etc.