The binary or base-two numeral system is a representation for numbers that uses a radix of two. It was first described by Gottfried Leibniz, and is used by most modern computers because of its ease of implementation using digital electronics--early 20th century computers were based the on/off and true/false principles of Boolean algebra. Binary can be considered the most basic practical numeral system (the Unary system is simpler, but impractical for most computation).
|
0101001101011 on off off on off on + - - + - + Y N N Y N Y
In keeping with customary representation of numerals using decimal digits, binary numbers are commonly written using the symbols 0 and 1. When written, binary numerals are often subscripted or suffixed in order to indicate their base, or radix. The following notations are equivalent:
When spoken, binary numerals are usually pronounced by pronouncing each individual digit, in order to distinguish them from decimal numbers. For example, the binary numeral "100" is pronounced "one zero zero", rather than "one hundred", in order to make explicit the fact that a binary numeral is being discussed, as well as for purposes of correctness. As we will see, the binary numeral "100" is equal to the decimal value 4, so it would cause confusion to refer to the numeral as "one hundred."
When the rightmost digit reaches 9, counting returns to 0, and the second digit is incremented. In binary, counting is quite similar, with the exception that only the two digits 0 and 1 are used. When 1 is reached, counting begins at 0 again, with the digit to the left being incremented:
Adding two "1" values produces the value "10", equivalent to the decimal value 2. This is similar to what happens in decimal when certain single-digit numbers are added together; if the result exceeds the value of the radix (10), the digit to the left is incremented:
This is known as carrying in most numeral systems. When the result of an addition exceeds the value of the radix, we "carry the one" to the left and add the next place value. Carrying works the same way in binary:
1 1 1 1 (carry) 0 1 1 0 1 + 1 0 1 1 1 ------------- = 1 0 0 1 0 0
Starting in the rightmost column, 1 + 1 = 10. The 1 is carried to the left, and the 0 is written at the bottom of the rightmost column. The second column from the right is added: 1 + 0 + 1 = 10 again; the 1 is carried, and 0 is written at the bottom. The third column: 1 + 1 + 1 = 11. This time, a 1 is carried, and a 1 is written in the bottom row. Proceeding like this gives the final answer 100100.
Subtraction works in much the same way:
In the binary system, however, it is customary to use the two's complement[?] notation for performing subtraction. Briefly stated, this notation represents a negative number, which can then be added to the first number to achieve the operation of subtraction.
In binary, multiplying by two amounts to moving all digits one position to the left and inserting a leftmost zero. This observation leads to the following faster conversion algorithm, a variant of the Horner scheme which does not require the computation of the powers of two: start with a result of zero and scan over the binary string from left to right. If the current digit in the string is a zero, multiply the result by two; if the current digit is a one, multiply the result by two and add one. Continue until you hit the right end of the binary string. Example:
In binary, the same relationship exists. Successively lower digits represent successively lower powers of the radix 2, beginning with an exponent of n-1, where n is the number of digits in the number. Consider a 5-digit binary number:
For a total of 2 + 4 + 16 = 22 in decimal. The left-most digit of this five-digit binary number represents the 24 position, or sixteens. The above procedure is one way to convert from binary into decimal.
The procedure for converting from decimal into binary is somewhat different. To convert from an integer decimal numeral to its binary equivalent, divide the number by two and place the remainder in the ones-place. Divide the result by two and place the remainder in the next place to the left. Continue until the result is zero.
An example:
Operation | Remainder |
---|---|
118/2 = 59 | 0 |
59/2 = 29 | 1 |
29/2 = 14 | 1 |
14/2 = 7 | 0 |
7/2 = 3 | 1 |
3/2 = 1 | 1 |
1/2 = 0 | 1 |
Reading the sequence of remainders from the bottom up gives the binary numeral 1110110.
Binary may be converted to and from hexadecimal somewhat more easily. This is due to the fact that the radix of the hexadecimal system (16) is a power of the radix of the binary system (2). More specifically, 16 = 24, so it takes exactly 4 digits of binary to represent one digit of hexadecimal.
The following table shows each 4-digit binary sequence along with the equivalent hexadecimal digit:
Binary | Hexadecimal |
---|---|
0000 | 0 |
0001 | 1 |
0010 | 2 |
0011 | 3 |
0100 | 4 |
0101 | 5 |
0110 | 6 |
0111 | 7 |
1000 | 8 |
1001 | 9 |
1010 | A |
1011 | B |
1100 | C |
1101 | D |
1110 | E |
1111 | F |
To convert a hexadecimal number into its binary equivalent, simply substitute the corresponding binary digits:
To convert a binary number into its hexadecimal equivalent, divide it into groups of four bits. If the number of bits isn't a multiple of four, simply insert extra 0 bits at the left (called padding[?]). For example:
And from binary to octal:
For a total of 3.25 decimal.
See also: Register, Unary, Ternary, Octal, Decimal, Hexadecimal, Floating point, p-adic numbers, truncated binary encoding.
Search Encyclopedia
|
Featured Article
|