Content
- 1 Binary system
- 1.1 The International System of Units and the term byte
- 1.2 Binary units in computer science
- 1.3 Nibble
- 1.4 Conversions
Binary system
The binary system has base 2 and is represented by the set {0, 1}
The International System of Units and the term byte
At the beginning of computing, units were shown as multiples of 1000, but in the 1960s 1000 began to be confused with 1024, since computer memory works on a binary basis and not a decimal basis
The problem was when naming these units, since the names of the prefixes from the International System of Units were adopted
Dada la similitud en las cantidades, se utilizaron los prefijos de base mil que se aplican a las unidades del sistema internacional (tales como el metro, el gramo, el voltio o el amperio)
However, etymologically it is incorrect to use these prefixes (decimal base) to name multiples in binary base
As in the case of the kilobyte, although 1024 is close to 1000
To clarify the distinction between decimal and binary prefixes, the International Electrotechnical Commission (IEC), a standardization group, proposed in 1998 other prefixes, which consisted of abbreviated unions of the International System of Units with the word binary
Thus, a set of 2^{10} bytes (1024 bytes), should be called a 4 kibibyte (KiB) contraction of Binary Kilobyte
This convention, expressed in the standards IEC 60027-2^5\text{ e }IEC 80000-13:2008, has been adopted for Apple's “Snow Leopard” operating system and by Ubuntu
Others, such as Microsoft, adopt the definition found in dictionaries such as Oxford's, by maintaining the use of "kilobyte" for 1024 bytes
In the computer environment, it has been suggested to use the capital K prefix to distinguish the binary quantity from the decimal, but this issue has not yet been standardized, since the symbol “K” in the SI represents the unit of temperature, the kelvin
On the other hand, this suggestion could not be extended to other prefixes of greater magnitude given that, in the case of the MB (megabyte), the IS already uses both the uppercase M (mega: million) and the lowercase M (milli: thousandth)
International System (decimal) | ISO/IEC 80000-13 (binary) | ||
---|---|---|---|
Multiple (symbol) | IS | Multiple (symbol) | ISO/IEC |
kilobyte (kB) | 10^3 | kibibyte (KiB) | 2^{10} |
megabyte (MB) | 10^6 | mebibyte (MiB) | 2^{20} |
gigabyte (GB) | 10^9 | gibibyte (GiB) | 2^{30} |
terabyte (TB) | 10^{12} | tebibyte (TiB) | 2^{40} |
petabyte (PB) | 10^{15} | pebibyte (PiB) | 2^{50} |
exabyte (EB) | 10^{18} | exbibyte (EiB) | 2^{60} |
zettabyte (ZB) | 10^{21} | zebibyte (ZiB) | 2^{70} |
yottabyte (YB) | 10^{24} | yobibyte (YiB) | 2^{80} |
Binary units in computer science
In pure mathematics a value does not have a space limit for its representation, however, machines generally work with a fixed number of bits
Bit
The smallest unit of information on a machine is called bit
With a bit, only one value of two different possible values can be represented, for example: zero or one, false or true, white or black, down or up, no or yes, etc
Nibble
A nibble is a collection of 4 bits
It wouldn't be an interesting type of data except that with a nibble you present a number BCD and also that a nibble can represent a digit hexadecimal
Byte
A byte is a collection of 8 bits
References to a certain memory location in all microprocessors are never less than one byte (most use multiples of bytes), therefore it is considered the smallest locatable (addressable) data
The bits are usually numbered from 0 to 7
The bit 0 is called bit of lower order or less significant, the bit 7 is considered the bit of the highest order or the most significant
A byte also consists of 2 nibbles, the bits 0, 1, 2 and 3 form the call nibble of a lesser order, and the bits 4, 5, 6 and 7 form the nibble of higher order
Since a byte is made up of two nibbles, It is possible to represent any value with two digits hexadecimals
Word
A word It's a group of 16 bits, the bit 0 is the bit of lower order and the bit 15 is the highest order
A word can be divided into 2 bytes called equally low and high order
Also a word can be considered as a group of 4 nibbles
A double word is considered to be a group of 32 bits
A quadruple word is considered to be a group of 64 bits
Modern computers typically have a word size of 16, 32, or 64 bits
Many other sizes have been used in the past, such as 8, 9, 12, 18, 24, 36, 39, 40, 48, and 60 bits
The slab is one of the examples of one of the first word sizes
Some early computers were decimal rather than binary, typically having a word size of 10 or 12 decimal digits and some early computers did not have a fixed word length
Sometimes the size of a word is defined to have a particular value for compatibility with older computers
Microprocessors used in personal computers (for example, Intel Pentium and AMD Athlon) are an example
Its IA-32 architecture is an extension of the original Intel 8086 design that had a word size of 16 bits
Los procesadores IA-32 siguen soportando programas del 8086 (x86), así que el significado de palabra en el contexto IA-32 sigue siendo el mismo y se continua diciendo que son 16 bits, a pesar del hecho de que en la actualidad (el tamaño del operando por defecto es 32 bits) operates more like a machine with a word size of 32 bits
Similarly in the new x86-64 architecture, one word is still 16 bits, aunque los operandos de 64 bits (quadruple word) are more common
Integer numbers
It is possible to represent a finite number of integer numbers
For example, with 8 bits we can represent 256 different objects
If a scheme were used positive integer numbers each of these objects would be numbered from 0 to 255
It is also possible to use a scheme negative integers numbers, for this case the system is used two's complement, where the bit of a higher order is the bit of sign, if such bit is zero, the number is positive, if it is one, the number is negative
If the number is positive it is stored in its standard binary value, if the number is negative it is stored in its standard binary form two's complement
Real numbers
The way computer architecture solves the problem of representing real numbers is through the numbers of floating-point
A number floating-point is divided into 3 sections of bits: sign, signifier and exponent with sign
Conversions
Conversion to the decimal system
The binary representation of a decimal number (the transition from a number in base 10 to its corresponding base 2), is calculated by successively dividing the quotient of the division of the number by the divisor 2, until obtaining a quotient less than 2
The representation in base 2 will be, the last quotient followed by the last remainder followed by the previous remainder followed by the previous remainder, and so on until the first remainder obtained
Example: Convert 3737 to binary representation
Number | Ratio | Rest |
---|---|---|
\frac{3737}{2} | 1868 | 1 |
\frac{1868}{2} | 934 | 0 |
\frac{934}{2} | 467 | 0 |
\frac{467}{2} | 233 | 1 |
\frac{233}{2} | 116 | 1 |
\frac{116}{2} | 58 | 0 |
\frac{58}{2} | 29 | 0 |
\frac{29}{2} | 14 | 1 |
\frac{14}{2} | 7 | 0 |
\frac{7}{2} | 3 | 1 |
\frac{3}{2} | 1 | 1 |
So we have to:
3737_{(10} = 111010011001_{(2}Convert from decimal to binary with decimal
The binary representation of a decimal number with decimals (the transition from a number in base 10 to its corresponding number in base 2)
It is calculated by successively multiplying the number (then the results) without its integer part by 2, until a number without decimals is obtained, up to a quantity that is repeated periodically (in the case of periodic numbers)
Or even a number of digits predefined by machine precision
The representation in base 2 will be the integer part without modifications, then the comma is added and finally the integer part of the result of the successive multiplications
Example: Convert 56.75 to binary representation with decimals
Number | Ratio | Rest |
---|---|---|
\frac{56}{2} | 28 | 0 | \frac{28}{2} | 14 | 0 | \frac{14}{2} | 7 | 0 | \frac{7}{2} | 3 | 1 | \frac{3}{2} | 1 | 1 |
So we have that the integer part is:
56_{(10} = 111000_{(2}
Number | Result | Integer part |
---|---|---|
0,75 \cdot 2 | 1,5 | 1 | (1,5 - 1) \cdot 2 | 1 | 1 |
So we have that the decimal part is:
0,75_{(10} = 11_{(2}
So we have to:
Convert from binary system to decimal
The decimal representation of a binary number would correspond to applying the formula:
b_1\cdot 2^{(n - 1)} + \cdots + b_n \cdot 2^0
Where n would be the length of the string and b_i the value corresponding to the i-th position of the string, starting from left to right
Example: Convert 111010011001 to decimal representation
111010011001_{(2}= 1 \cdot 2^{11} + 1 \cdot 2^{10} + 1 \cdot 2^9 + 0 \cdot 2^8 + 1 \cdot 2^7 + 0 \cdot 2^6 + 0 \cdot 2^5 + 1 \cdot 2^4 + 1 \cdot 2^3 + 0 \cdot 2^2 + 0 \cdot 2^1 + 1 \cdot 2^0 = 2048 + 1024 + 512 + 0 + 128 + 0 + 0 + 16 + 8 + 0 + 0 + 1 = 3737_{(10}
So we have to:
111010011001_{(2}=3737_{(10}
Convert from binary system to decimal with decimal places
If the number also has decimals, it will be expressed with the following formula:
b_1\cdot 2^{(n - 1)} + \cdots + b_n \cdot 2^0+b_{n+1}\cdot 2^{-1} + \cdots + b_{n+m} \cdot 2^{-m}
Where n would be the length of the string without decimals, m the length of the string with decimals, b_i the value corresponding to the i-th position of the string, starting from left to right
Example: Convert 111000.11 to decimal representation
111000,11_{(2}=1 \cdot 2^5 + 1 \cdot 2^4 + 1 \cdot 2^3 + 0 \cdot 2^2 + 0 \cdot 2^1 + 0 \cdot 2^0 + 1 \cdot 2^{-1} + 1 \cdot 2^{-2} = 32 + 16 + 8 + 0 + 0 + 0 + 0 + 0,5 + 0,25 = 56,75(10
So we have to:
111000,11_{(2}=56,75(10