omar / ByteSize

ByteSize is a utility class that makes byte size representation in code easier by removing ambiguity of the value being represented. ByteSize is to bytes what System.TimeSpan is to time.
MIT License
558 stars 50 forks source link

0 defaults to bits (b) whereas all other values defaults to bytes (B) #42

Closed mintsoft closed 2 years ago

mintsoft commented 3 years ago

Basically:

Console.WriteLine(ByteSize.FromBytes(0).ToString()); outputs 0b Console.WriteLine(ByteSize.FromBytes(1).ToString()); outputs 1B

image

This looks really messy when it's used to format a whole table of results etc, it's very rare to actually "see" bits in the wild as most things are usually measured in Bytes. I'm advocating to change the default unit of "0" to be bytes.