Binary

From Wikipedia

HomePage | Recent changes | View source | Discuss this page | Page history | Log in |

Printable version | Disclaimers | Privacy policy

Astronomy

A stellar system that consists of two nearby stars that revolve against a common center of gravity.

See also Binary stars, Optical binary.

Mathematics and Computer Science

The base two or binary number system is a representation for numbers that uses only zeroes and ones as digits. It is used by practically all computers because of its ease of implementation using digital electronics and Boolean algebra. It was first described by Gottfried Leibniz.

As in all place-based number systems, the location of each digit is significant. The right most digit (or the first digit to the left of the decimal point if the number contains a decimal point) corresponds to the ones-place (20 = 1) and the value represented by that digit is simply the digit (1 or 0) multiplied by 1. The digit to the left of the one-place corresponds to the 21-place, so that digit represents (1 or 0) multiplied by 21. The next digit corresponds to 22 (= 4) and so on. Digits to the right of the decimal place correspond to 2-1, 2-2, ...

To obtain the Decimal equivalent of a binary number, simply multiply the various digits by their appropriate place-values and add the results together. For example:

101101001 = 1×28 + 0×27 + 1×26 + 1×25 + 0×24 + 1×23 + 0×22 + 0×21+ 1×20 = 256 + 64 + 32 + 8 + 1 = 361
101.011 = 1×22 + 0×21 + 1×20 + 0×2-1 + 1×2-2 + 1×2-3 = 4 + 1 + 0.25 + 0.125 = 5.375

Multiplying a binary number by 2 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:

To convert the binary number 101101001 into decimal: 0 * 2 + 1 = 1, 1 * 2 = 2; 2 * 2 + 1 = 5; 5 * 2 + 1 = 11; 11 * 2 = 22; 22 * 2 + 1 = 45; 45 * 2 = 90; 90 * 2 = 180; 180 * 2 + 1 = 361.

To convert from an integer decimal number 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. For example:

OperationRemainder
118/2 = 590
59/2 = 291
29/2 = 141
14/2 = 70
7/2 = 31
3/2 = 11
1/2 = 01

Reading the sequence of remainders from the bottom up gives the binary number 1110110.



See also Register, Decimal, Hexadecimal, Octal, Floating point, p-adic numbers.