Skip to content
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

fix: use standardized units in text outputs #3784

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

n-peugnet
Copy link
Contributor

@n-peugnet n-peugnet commented May 26, 2024

The small b was misleading as it usually means "bit", whereas here we have "bytes". Also, the prefixes k, m and g did not match any existing convention, here as we are dividing by 1024, we should use Ki, Mi and Gi to prevent any confusion.

See: https://en.wikipedia.org/wiki/Byte#Multiple-byte_units

EDIT: sorry, after more testing I noticed it now looks misaligned.
EDIT2: fixed.

@n-peugnet n-peugnet marked this pull request as draft May 26, 2024 16:22
@n-peugnet n-peugnet marked this pull request as ready for review May 26, 2024 17:27
@n-peugnet
Copy link
Contributor Author

@evanw what do you think about this?

@evanw
Copy link
Owner

evanw commented Jul 4, 2024

I've never heard someone say "kibibyte" and I would be very confused if someone had. I've only ever heard people use "kilobyte". So for me it would cause more confusion, not less.

@n-peugnet
Copy link
Contributor Author

n-peugnet commented Jul 4, 2024

Of course, the most important part of my proposition was the capital B instead of the lowercase one. But this lead to also modifying the prefix.

Here we have 3 possibilities as explained in the Wikipedia article that I linked:

  1. The SI prefix (kB, MB, GB, etc.), but we would then have to divide by 1000 instead of 1024 to be conformant with the standard, which is very uncommon in software.

  2. The JEDEC definition (KB, MB, GB) while keeping the division with 1024, but as stated in the definition:

    The definitions of kilo, giga, and mega based on powers of two are included only to reflect common usage. IEEE/ASTM SI 10‑1997 states "This practice frequently leads to confusion and is deprecated."

    Indeed, for values other than kB/KB, how can we know if the standard used is the SI or the JEDEC, and thus a division by 1000 or 1024 ?

  3. The IEC standard (KiB, MiB, GiB, etc.) which leaves no ambiguity and matches the current behavior.

Sure you could go for option 2. but it is deprecated and IEC standard is becoming more and more common, for example Webpack (webpack/webpack@9732e37) and Git are using it but there are a lot more.

@n-peugnet
Copy link
Contributor Author

Also, as you seem to be using MacOS, it seems the Finder uses neither of these standards/conventions (JEDEC-like prefix with base 10 divisions). As you can see, the size of a MB or GB is far from universal. This is why IMO the IEC standard is the least confusing of all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants