- Output display data unit
In the Computer Science world, a
byte is the unit of the information which is based on the binary system (base 2 unlike decimal system which has base 10). A byte consists of 8bit s (binary digits) and is considered to be the smallest measurable unit i.e. any data stored on the computer storage cannot normally be less than a single byte.The non-technical people uses decimal system and hence there is slightly difference in the measurement prefixes (known as SI prefixes) attached with the decimal system and bytes.
In 1998, the
IEC , then theIEEE , published a new standard describingbinary prefix es:But as the Binary prefix was not standardized earlier, these two styles (SI prefix and binary prefix) are used loosely at the same time. This causes discrepancies in the values computed by the various commands for the same source of data i.e. while reporting the size of the data stored, some of the commands uses 1000 bytes as 1Kbytes (SI prefix value) while some other uses 1024 bytes as 1Kbytes (Binary prefix). Ideally the command should display the standard prefix convention along with the value so that end users are aware that whether it is 1K or 1Kibi.
Many computer users have impression that all the calculation and display data are in terms of binary definition i.e. in terms of power of 2 which is not the case always. Hence there are discrepancies in the unit used by the commands to display the size / capacity.
In order to address this confusion, currently all relevant standards bodies promote the use of the term binary prefix for the binary definition.
This page will look into various components of a Computer system where the size calculations are involved and will try to list down the corresponding used prefix values for the same.
Hardware data unit
# Computer Memory: RAM, ROM and Flash ,,,Butt Plug
#: When referring to RAM sizes, it traditionally has a binary definition of GB (1024³ bytes).
# Computer storage: HardDisk / Flash drives
#: It uses decimal definition of GB (10003 bytes).
# Telecommunication (Network speed)
#: It uses decimal definition of GB (10003 bytes).
# Processor clock speed
#: It uses decimal definition of GB (10003 bytes).
#: So a 1 GHz processor performs 1,000,000,000 clock ticks per second.UNIX / Linux Command data unit
The Operating systems generally uses binary definition of gigabyte (1,073,741,824 bytes, equal to 1024³, or 230 bytes) to display disk capacity, file size, or system RAM size while the storage manufacturers uses decimal definition of gigabyte (1,000,000,000 bytes) and hence it causes the confusion. For example, a hard disk with a manufacturer rated capacity of 400 GB (decimal definition) may have its capacity reported by the operating system as only 372 GB (binary definition).
In UNIX based systems, the user space commands output data unit is not uniform on the basis of the above two categories i.e. binary definition and decimal definition. This causes the size discrepancies in between different commands.
This section will try to list down the display unit used by various Linux / UNIX based user space commands.
Commands reporting size in binary version (i.e. GiB)
These commands unfortunately not using the new unit’s abbreviation. These commands do their calculation so as to return Gibibytes but then fail to use the "GiB" unit so the user knows it did that.
The commands displaying file size and memory size (RAM) generally uses Binary version i.e. in terms of power of 2.
"ls" command:
adil@host:~> ls -l 1GB_file
-rw-r--r-- 1 adil users 1073741824 2008-01-03 23:17 1GB_file
adil@host:~> ls -lh 1GB_file
-rw-r--r-- 1 adil users 1.0G 2008-01-03 23:17 1GB_fileCommands reporting size in decimal version (i.e. GB)
The commands displaying disk space or file usage uses SI prefix i.e. in terms of power of 10.
“du” command:
adil@host:~> ls -alh 2GB_file
-rw-r--r-- 1 adil users 2.0G 2008-01-04 22:15 2GB_file
adil@host:~> du -h 2GB_file
2.1G 2GB_fileIn the above example, the "ls" command uses the binary prefix definition and reported the (2147483648) bytes of file as 2.0G file. Ideally it should display as 2.0GiB to convey the end user that it is using the binary prefix value. On the other hand the du command uses the SI prefix value and reports (2147483648) bytes of file as 2.1G file.
This will surprise the user that how these two commands are reporting size of the same file different.
“fdisk” command:
Disk /dev/sda1: 10.7 GB, 10701057024 bytes"fdisk" shows the disk partition information including the size. In the above example the /dev/sda1 partition is of 10701057024 bytes and reporting it as 10.7 GB which means it is using the SI prefix value. If we calcualte the same size on binary prefix, it comes to 9.96 GB.
Discrepancy / error ratio due to data unit difference
Calculation for 2147483648 bytes
In binary definition:
2147483648 / 10243 = 2.000
In decimal definition:
2147483648 / 10003 = 2.14748 which rounds to 2.1This discrepancy gets worse as data sizes grow:
KB v. KiB = 2.4% error
MB v. MiB = 4.8% error
GB v. GiB = 7% error
TB v. TiB = 11% error
PB v. PiB = 15% errorGiven that you can buy a TB size drive for $500, but the 11% difference is just too much to ignore. So it is the right time for all this to get straightened out.
ee also
*
du (Unix)
*Gibibyte
*Gigabyte
Wikimedia Foundation. 2010.