Saturday, September 12, 2009

Revised HD Saving: Snow Leopard OS

Recently I started to tack space changes before and after a new software or a update being installed. I noticed that the values I get from Get Info (from HD's context menu) is different from the values I get from the command of "df -lhg" in Terminal. I posted a question about this to Apple's discussion forum.

Quickly I got the explanation: the flag "h" is for GB in binary base, i.e., 1,073,741,824. I should use the flag of "H" for decimal base: 1,000,000,000 since the values in Get Info are in decimal base. The correct command in Terminal to get the similar decimal values should be:

   $: df -lHg

The ratio of the different bases is 1.073741824. In the words, for each decimal value of 1 GB, the binary value has about 0.073741824 factor less since the binary base is slightly larger than the decimal base. When you have HD space about 400-600 GB (decimal base), the decimal value has about 29-44 GB more than binary based values. They are in different bases. The real values are the same. However, the values in binary base is more actuate in terms of computer world because the information are written to disk in binary.

By the way, the values in Get Info is up to two decimal precision, while the results of the command of df are all integers.

It is quite interesting I found that the Get Info of the pre-Snow Leopard OS(or Leopard as far I know) uses binary based values, while the Snow Leopard OS starts to use decimal values. I was not aware about this. The numbers of my notes about before and after Snow Leopard installation are from Get Info. They are ACTUALLY based in different bases. So my blog of the space difference calculation was wrong. The following is the correct calculation:

Before(binary base) 465.44 266.85 198.59(211,092,037,632)
After (decimal base) 499.76 299.3 200.47(200,067,039,464)
After' (binary base) 465.44 278.74 186.7(186,326,950,289)
Difference (A'-B)011.89-11.89(-11,024,998,168)

Here the binary base is the base of one byte. In this base,

1 Kilobyte is 1,024-byte (1-Kbyte) or 2**10 ,
1 Megabyte is 1,048,576-byte (1-Mbyte) or 2**20, and
1 Gigabyte is 1,073,741,824-byte (1-Gbyte) or 2*30.

While on the decimal base,

1KB is 1,000 bytes,
1MB is 1,000,000 bytes, and
1GB is 1,000,000,000.

Therefore, the decimal base values cannot be exactly represented by 2 power base.

No comments: