Determining File Size
Determining File Size
On a Macintosh computer, the file sizes you see in the finder aren't the size of the file, but are actually the number of bytes being taken up on a particular disk by the file. Each file on a disk (Mac or PC) occupies one or more allocation units; the exact number depends on the the file size and the disk's allocation unit size. The allocation unit is determined when formatting the disk. In the file listing below taken from the Macintosh finder, notice that all of the numbers below "size" are a multiple of 31K?


The reason is that 31K happens to be the allocation unit for this particular hard disk. What exactly is an allocation unit you say? An allocation unit is a unit of space on a hard disk, and different disks have different allocation units. More importantly, a file has to take up disk space in multiples of the allocation unit. For example, if I have a 15K file and my disk's allocation unit is 31K, then that 15K file will take up 31K of disk space. If my file happens to be 32K and my disk allocation unit is 31K, then you guessed it, my file actually takes up 62K (almost double the needed space). Most of the time, the allocation unit is lower, but on very big hard drives, it can even become larger. You say that's a waste of space? You're right, but it takes place everyday on your Mac or PC.

The Mac gives you the ability to see both the disk allocation of a file and the file size, unlike the PC. On the Mac, you can use the "Get-Info" command from the desktop File menu to see both the file size and the amount of disk space it uses. Take a look below:



Notice that the size on disk says 62K. This is the amount of space that this image is taking up on this particular disk; it could be different on a different disk. The main point here is that because all disks have different allocation units, we are only concerned with the actual size of the file. The size of the file we are getting information about in this example (located next to the size on disk) is 32,099 bytes, or roughly 32K (really 31K and some change). To get the 31K, just divide the total number of bytes by 1024 to get the total number of kilobytes (1K = 1024 bytes).

Now the PC differs in this area in that it only gives you the size of the file when you get a list of files. If you want to find out how much disk space the file is taking up on the PC (or any system for that matter), you have to apply the following formula:


    (file size + allocation unit -1) / allocation unit

    now take the integer part of your answer and multiply by the allocation unit


Now that you've struggled through that, you need to know that you probably shouldn't be concerned. Unless you were very short on disk space you probably wouldn't care to find the amount of disk space that a particular file takes up. Only the actual file size of your image will usually be important to you.