3

Why does the Finder show a file as "129,900 bytes (131 KB on disk)"?

129900 bytes = 126.86 KB

If you round it off to the nearest 4k boundary the size cannot be 131kb. I am confused, can anyone help?

2
  • Are you sure your disk is using 4KB clusters? Jan 28, 2012 at 5:33
  • 3
    @techie007, since he said he's on a Mac, and Macs usually use HFS+ volumes, which use 4KiB blocks nowadays, the answer is probably "yes". BTW "clusters" is a Microsoftism which applies to FAT and NTFS. HFS+ uses the term "logical block" or just "block".
    – Spiff
    Jan 28, 2012 at 6:27

5 Answers 5

5

No, that's correct.

128KiB = 131072B = 131kB

10

Apple chose to stop using Kibi/Mebi/GibiBytes (1,024's, 1,048,576's, and 1,073,741,824's of bytes) in displaying file sizes in recent versions of Mac OS X. As of Lion and possibly Snow Leopard, it reports things in true kilo/mega/gigaBytes (1,000's, 1,000,000's, and 1,000,000,000's of bytes)

You're right that HFS+ typically uses 4096 byte blocks nowadays. So if your file is a little over 126,976 bytes in length, it won't fit in 31 blocks, so it'll use part of a 32nd block, so in some cases where just the blocks used are counted instead of the exact size of file, it may be listed as being 131,072 (rounded to 131KB) in length.

3
  • i have a small code to display the size,how would i write code
    – Manish
    Jan 28, 2012 at 6:24
  • @Manish I can't understand what you're asking with that comment.
    – Spiff
    Jan 28, 2012 at 6:30
  • sorry, it committed in middle.
    – Manish
    Jan 28, 2012 at 6:35
5

31 4KiB clusters is 126,976 bytes. Not enough to hold the 129,900 bytes. 32 4KiB clusters is 131,072 bytes. That's enough to hold the 129,900 bytes. So it's using 32 4KiB clusters, or 128KiB which is 131,072 bytes or about 131KB.

3

macOS displays KB (1024's of bytes) when it's actually kB (1000s of bytes). This is seemingly a bad terminology in macOS itself.

The issue is obscured by the fact that the number in parenthesis is a combination of two things:

  1. Size on disk (which involves filesystem cluster size etc.)
  2. Conversation from bytes to kilobytes.

But if you use ls with the right flags in Terminal, you can see that what Finder is displaying is actually kilobytes (kB) not KibiBytes (KB or KiB).

-1

The size of the file is 129900 bytes = 126.86 KB. The amount of space it is using on your hard drive is 131KB. To put it in simple terms.. This happens because your file system on the hard drive has several clusters. Each cluster may be only a few kilobytes. However, when the file is written to the hard drive, it may not use up a full cluster. Even if it did not use up a full cluster, that memory is essentially unavailable.

2
  • I believe "clusters" is a term from the FAT file system family that doesn't apply to HFS+. Of course he could be talking about a file on a FAT-formated drive, but it's not likely.
    – Spiff
    Jan 28, 2012 at 6:21
  • 129,900 bytes may be 126.86KiB, but it's 129.9KB. The difference matters here because we're talking about sizes on disk. Jan 28, 2012 at 7:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .