Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
Support binary and decimal bytes (i.e. 1 kibi = 1024 b and 1 kb = 1000 b) #24
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.
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