0

For example, I've just downloaded a file that's 4.67 GiB.

In Windows 10, when I go into the properties, it lists the following:

Showing as 5,023,979,520 bytes

Size on disk is 5,023,981,568 bytes

On Linux, it's listed as 5,023,979,520 bytes.

When you use an online calculator to convert to 4.67 GiB to bytes, you get 5014374318.08.

Can anyone explain why there's a difference here? I'm guessing it's potentially overhead added by the respective file systems? NTFS and EXT4 are showing the same size.

Will
  • 11

2 Answers2

2

5023979520 B is the exact value. It was converted to gibibytes and apparently rounded (down) to two decimal places. The result is 4.67 GiB and it's an approximate value because of rounding.

# in Linux
$ dc -e '2k 5023979520 1024 3 ^ / p'     # 2k sets precision, the rest is math in RPN
4.67

5023979520 B is exact, 4.67 GiB is approximate. Not the other way around.

If you do it the other way around, i.e. if you treat 4.67 GiB as the exact value and convert it to bytes, then yes, you will get 5014374318.08 B.

# in Linux
$ dc -e '2k 4.67 1024 3 ^ * p'     # 2k sets precision, the rest is math in RPN
5014374318.08

Now if you realize 4.67 GiB was an approximation in the first place, then you will acknowledge that 5014374318.08 B must be an approximation to a similar degree.
Indeed 5014374318.08 = 5023979520 ±1%.

1

You are confused between GB (Gigabyte) - 1000 & GiB (Gibibyte) - 1024. See "gigabyte" on Wikipedia.

If you take 5,023,979,520 and continually divide by 1024, you get to 4.6789455413818359375 GiB - give or take a fraction.

For the size on disk, you have to think about block sizes, where the remainder of a file, even if a few bytes, will take up a full block. This is what will happen for many filesystems. However, there are a few filesystems which will use an alternative method of storing those few remainder bytes, usually within the inode structure, especially on Linux.

Therefore if you take 5,023,981,568 and divide it by 4,096, you will get 1,226,558 exactly. This means that the file is taking up that exact amount of 4,096 byte blocks.

Bob Goddard
  • 1,482