Incorrect use of MB vs MiB

digitalpoint

Well-known member
Affected version
2.2.13
I'm aware that this is pretty nitpicky, but XenForo is using a base 1024 system for filesystem sizes and then incorrectly labeling them as KB, MB, GB, TB, etc (those are base 1000 labels) in XF\Language.php.

See: https://en.wikipedia.org/wiki/Megabyte

1691603064798.png

The numbering system XenForo uses is KiB, MiB, GiB, TiB, etc.

Not a huge deal in itself as it's mostly cosmetic, but it starts to get weird when you are comparing things like attachment sizes in XenForo to a system where they are labeled correctly and the underlying numbers don't match. You end up needing to do some kludgy stuff in templates to "undo" XenForo's "incorrectness" so things match up:

Code:
<xf:macro name="file_size" arg-size="!"><xf:trim>
    <xf:comment>Kind of dumb, but XenForo is using base 1024 and labeling it as if it's base 1000, so in order for it to match Cloudflare's stats (they are doing it correctly), we need to adjust what XenForo presents.</xf:comment>
    <xf:if is="$size >= 1024"><xf:set var="$size" value="{{ $size * 1.024}}" /></xf:if>
    <xf:if is="$size >= 1048576"><xf:set var="$size" value="{{ $size * 1.024}}" /></xf:if>
    <xf:if is="$size >= 1073741824"><xf:set var="$size" value="{{ $size * 1.024}}" /></xf:if>
    <xf:if is="$size >= 1099511627776"><xf:set var="$size" value="{{ $size * 1.024}}" /></xf:if>
    {{ file_size($size) }}
</xf:trim></xf:macro>
 
I don't care how "correct" they are, I've been using computers since the early 80s (1K ZX81 had 1024 bytes, not a paltry 1,000) and working in various IT fields since the mid 90s and not once have I ever heard or seen anyone use the terms "kibibyte", "mebibyte", or "gibibyte".

I bet you pronounce it JIF too.
 
Me either… my vote is make the numbers base 1000 and then it’s correct staying as megabyte. 😀

The issue is that XenForo is using MiB (numerically). Like if I have a 501.6 MB file from my computer, the computer presents it as, 501,633,024 bytes (501.6 MB on disk). Which is correct... it's 501.6 megabytes. Upload that file to XenForo as an attachment, and XenForo says it's a 478.4 MB file... when it's in fact a 478.4 MiB file (a.k.a. 501.6 MB). I just "lost" 23.2 MB of the file I uploaded?
 
Last edited:
I don't care how "correct" they are, I've been using computers since the early 80s (1K ZX81 had 1024 bytes, not a paltry 1,000) and working in various IT fields since the mid 90s and not once have I ever heard or seen anyone use the terms "kibibyte", "mebibyte", or "gibibyte".

I bet you pronounce it JIF too.

It really wasn't until the storage companies figured this was a good way to rip off people by short changing them storage by switching the computer kilo, mega, etc. terminology to be base 10 instead.

Its a very significant amounts of "missing" storage these days considering the size. My "8TB" drive is missing about 700GB.
 
Although I disagree on XenForo decision, this is "as designed".

 
I understand that Windows mislabels MiB as MB, but that’s not a particularly great reason to also do it. I’m not suggesting to start labeling things as MiB, rather do the math as base 1000 rather than base 1024 like everything else does (except Windows). Even uploading files from my phone… phone labels it as 3.1 MB (correct), then XenForo shows it as 3.0 MB (incorrect because I guess that’s how Windows also does it and we think Windows is so good we should emulate what it does wrong? 🤷🏻‍♂️)

IMG_6014.jpeg
IMG_6015.jpeg

Like XenForo, MacOS used to also do it incorrect (probably for the same reason... because Windows does it), but they fixed it eventually (in Mac OS X 10.6... 12 years ago). Hopefully XenForo will also reconsider.

Where it starts to get weird is when you are trying to compare sizes you see in XenForo to what you see outside. For example if Cloudflare shows data served for your site as 4.2 GB and XenForo shows the same data (from the same source) as 4.0 GB.

1691681881438.png

Same when using R2 for attachments... the numbers don't jive with what XenForo says because XenForo is using base 1024 when it should be using base 1000.

1691682494387.png

Compared to what XenForo says the file sizes are:

1691682684002.png

It just doesn't make sense to me to continue to present it incorrectly if the reasoning behind it is because, "Well, Windows does it wrong too..." everything else (besides Windows) does it correct and it's causing problems when the numbers don't align.
 
It just doesn't make sense to me to continue to present it incorrectly if the reasoning behind it is because, "Well, Windows does it wrong too..." everything else (besides Windows) does it correct and it's causing problems when the numbers don't align.

When the majority (70%) of the world does it a particular way, surely that makes it "correct"? 😝

See also my favourite made up quote: "The great thing about standards: there's so many to choose from!" 😎
 
When the majority (70%) of the world does it a particular way, surely that makes it "correct"? 😝
I don’t really follow the logic of that one. It just makes it popular (or populist) as opposed to correct. But even then do you think that 70% actually know the difference and are making an informed choice regarding storage measurement?
 
I don’t really follow the logic of that one. It just makes it popular (or populist) as opposed to correct. But even then do you think that 70% actually know the difference and are making an informed choice regarding storage measurement?

There was no logic. It was a sarcastic joke - hence the emoji :rolleyes:
 
I've always understood data to be stored as binary (Base 2), so a megabyte to me has always been 1024 bytes. So 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024 etc.
 
Back
Top Bottom