There are 2 types of data size units. The base 2 sizes and the base 10 sizes. Most systems use base 2 sizes. Base 10 sizes are only really shown on drive sizes.

The common unit in both types of units is the Bytes. The IEC byte and SI byte are the same, so if converting between the 2 (I recommend going back to the byte first). 1 byte = 8 bits

Ex: So if converting from KiB to TB. You can first convert the KiB to Bytes. Then Bytes to TB.

Its just that 1 KiB (kibibyte, commonly incorrectly called the kilobyte) = 1024 bytes
While the 1 KB (kilobyte) = 1000 bytes
and so on…

More on this topic: https://en.wikipedia.org/wiki/Byte

IEC UNITS – base 2
####################

* Proprely prefixed like this: KiB,MiB,GiB,TiB
* Also commonly shown as: K, M, G, T
* Microsoft and common products incorrectly prefix it like this: KB, MB, GB, TB (as if they are referring to the SI units, however they are indeed referring to the base 10 IEC units). Ex: you plug in 1000 GB drive (drive manufacturers correctly label their units) into a PC. The Windows PC then shows that you have about 930 GB. Where did that 70 GB go? It went nowhere – its still there – The Windows UI should instead label it as 930 GiB (add the i, to make the unit clear) or change the label to 1000 GB.

Conversion example using exponents:

Start with 9603064438784 bytes

Lets use awk to divide by 1024, then divide by 1024*1024, then by 1024*1024*1024, finally by 1024*1024*1024*1024 to get different scales

# echo 9603064438784 | awk ‘{print $1/1024}’
9.37799e+09 KiB

# echo 9603064438784 | awk ‘{print $1/2^10}’
9.37799e+09 KiB

# echo 9603064438784 | awk ‘{print $1/(1024*1024)}’
9.1582e+06 MiB

# echo 9603064438784 | awk ‘{print $1/2^20}’
9.1582e+06 MiB

# echo 9603064438784 | awk ‘{print $1/(1024*1024*1024)}’
8943.55 GiB

# echo 9603064438784 | awk ‘{print $1/2^30}’
8943.55 GiB

# echo 9603064438784 | awk ‘{print $1/(1024*1024*1024*1024)}’
8.73394 TiB

# echo 9603064438784 | awk ‘{print $1/2^40}’
8.73394 TiB

What to remember:
Every ten multiplications of 2 is 1024
1024 = 2^10
1024*1024 = 2^20
1024*1024*1024 = 2^30
1024*1024*1024*1024 = 2^40

with respect to dividing by 2^x:
bytes->10->KiB
bytes->20->KiB->MiB
bytes->30->KiB->MiB->GiB
bytes->40->KiB->MiB->GiB->TiB
SI UNITS – base 10
####################

* Proprely prefixed like this: KB, MB, GB, TB
* Drive manufacturers use this unit correctly. So 1000 GB drive is indeed 1000,000,000,000 bytes (and a few extra bytes here or there that dont change the count by much)

conversion example using exponents:

Start with 9603064438784 bytes

# echo 9603064438784 | awk ‘{print $1/1000}’
9.60306e+09 KB

# echo 9603064438784 | awk ‘{print $1/10^3}’
9.60306e+09 KB

# echo 9603064438784 | awk ‘{print $1/(1000*1000)}’
9.60306e+06 MB

# echo 9603064438784 | awk ‘{print $1/10^6}’
9.60306e+06 MB

# echo 9603064438784 | awk ‘{print $1/(1000*1000*1000)}’
9603.06 GB

# echo 9603064438784 | awk ‘{print $1/10^9}’
9603.06 GB

# echo 9603064438784 | awk ‘{print $1/(1000*1000*1000*1000)}’
9.60306 TB

# echo 9603064438784 | awk ‘{print $1/10^12}’
9.60306 TB

What to remember:

Every 3 multiplications of 10 is 1000
1000 = 10^3
1000*1000 = 10^6
1000*1000*1000 = 10^9
1000*1000*1000*1000 = 10^12

with respect to dividing by 10^x:
bytes->3->KB
bytes->6->KB->MB
bytes->9->KB->MB->GB
bytes->12->KB->MB->GB->TB

Leave a Reply

Your email address will not be published. Required fields are marked *