The byte
unit of sl-format-bytes
: Add support for base 1024 (binary)
#1950
patricknelson
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I noticed that out of the box, the
sl-format-bytes
component (demo in docs) assumes that the bytes provided are following the base 10 convention (decimal). It’s still quite common to compute magnitudes of bytes (i.e. megabytes, gigabytes, etc) using the binary base 1024 convention (or 2 to the power of some number).So, for example, using the 1024 convention, 1 KB = 1024 bytes, 1 MB = 1024 KB = 1048576 bytes and so on. However,
sl-format-bytes
will convert 1024 to 1.02 kB instead of 1 kB (also, not sure whykB
is used instead ofKB
). This difference increases slightly as the number goes up (e.g. 1 GB becomes 1.07 and etc).I’m not certain if this was intentional or not, which is actually part of the fun (and confusion) of byte conversion 😅! Wikipedia has a good article on this.. So, I figured I’d submit this as a feature request instead, in case this was intentional. Probably best anyway to prevent breakage or confusion.
Beta Was this translation helpful? Give feedback.
All reactions