0

The Ubuntu file system says my file is 5.2MB. When I right click on the file I can see the file size in bytes is stated as 5,154,017.

File properties screen grab

Doing some simple maths we can calculate that in MB:

5154017 / 1024 = 5033.219726562KB

5033.219726562 / 1024 = 4.915253639MB

How does Ubuntu determine the 'rounded' value of the file size displayed in the files dialog? - This question may not be Ubuntu specific.

It does not appear to be using normal rounding e.g. half up which would display as 5MB.

wjandrea
  • 14,236
  • 4
  • 48
  • 98
Suipaste
  • 103

2 Answers2

1

Ubuntu uses the
bytes > kilobytes > megabytes system
(1000 bytes = 1 kilobytes, 1000 kilobytes = 1 megabytes)
instead of the
bytes > kibibytes > mebibytes system
(1024 bytes = 1 kibibytes, 1024 kibibytes = 1 mebibytes).

So 5154017 bytes = 5.154017 megabytes ≈ 5.2 megabytes.

pomsky
  • 68,507
0

Ubuntu always makes the distinction between base-10 prefixes (kilo, mega, giga, etc) and base-2 prefixes (kibi, mebi, gibi, etc). That is, you will never see mebibytes (mis)labeled as megabytes. So in this case, 5.154 MB rounds to 5.2 MB.

See Units Policy on the wiki for more details.

wjandrea
  • 14,236
  • 4
  • 48
  • 98
  • In context of file sizes in an operating system, "MB" and the term "megabyte" has pretty much exclusively meant 1024x1024 bytes throughout computing history. While I can appreciate the logic and "correctness" of the push to switch to 1000x1000 instead, it's taking it a bit far to label all previous usage of "MB" and "megabyte" as 1024x1024 bytes in computing history as incorrect. Remember that "mebibyte" is a much more recent term for that quantity and acts as a disambiguator because "megabyte" has meant both. – thomasrutter Dec 12 '17 at 00:51
  • @thomasrutter Hey, don't look at me, I didn't write the Units Policy ;) – wjandrea Dec 12 '17 at 00:57
  • I don't disagree with the units policy, I disagree that everyone who has used MB/megabytes to refer to 1024x1024 has misused the term. The units policy itself acknowledges how this is standard practice in a lot of contexts. – thomasrutter Dec 12 '17 at 01:05
  • @thomasrutter Oh, I see what you mean. I wrote "(mis)labeled" because in Ubuntu, the words are strictly defined. – wjandrea Dec 12 '17 at 01:09