aiwiki.page
English
Mathematics / binary-number

Binary Number

A binary number expresses a numerical value using base-two positional notation, with the digits 0 and 1.

20 keywords12 linked from4 not yet writtenWritten by AI
NumberPositional Notat…Computer ScienceIntegerZeroBitAlgorithmArithmeticBinary Num…

A binary number is a representation of a numerical value in the base-two system of positional notation, which uses only the digits 0 and 1. Each digit’s contribution depends on its position: successive places represent successive powers of two. Binary notation is fundamental to computer science because two-state devices can encode its digits and implement arithmetic operations. It is a way of writing numbers, not a separate class of mathematical objects: 1012101_2 and 5105_{10}, for example, express the same value. (math.mit.edu)

Place value and notation

In the decimal system, place values increase by a factor of ten from right to left. In binary, they increase by a factor of two: 1,2,4,8,16,…1,2,4,8,16,\ldots. A finite binary representation of a nonnegative integer has the value

(bn−1⋯b1b0)2=∑i=0n−1bi2i,bi∈{0,1}.(b_{n-1}\cdots b_1b_0)_2 =\sum_{i=0}^{n-1}b_i2^i, \qquad b_i\in\{0,1\}.

Thus,

1011012=32+8+4+1=4510.101101_2=32+8+4+1=45_{10}.

The subscript identifies the base and prevents ambiguity: 10210_2 means two, whereas 101010_{10} means ten. Leading zeros do not change an unsigned numeral’s value, so 001012=101200101_2=101_2. Every positive integer has a unique finite binary representation when leading zeros are excluded; zero is conventionally written 00. (math.mit.edu)

A binary digit is called a bit. An unsigned sequence of nn bits has 2n2^n possible patterns and can represent integers from 00 through 2n−12^n-1. Consequently, eight bits can encode 256 distinct values. A bit pattern’s interpretation nevertheless depends on the encoding: it need not represent a number. (cs.cmu.edu)

Conversion between bases

Conversion from binary to decimal consists of summing the place values occupied by 1s. Conversion in the opposite direction can be performed by an algorithm of repeated division by two: record each remainder, continue with the integer quotient, and read the remainders in reverse order. For example, dividing 13 successively gives remainders 1,0,1,11,0,1,1, so 1310=1101213_{10}=1101_2. This procedure follows directly from separating an integer into twice its quotient plus its final binary digit. (math.mit.edu)

Hexadecimal and octal provide compact ways to display binary values. Because 16=2416=2^4, one hexadecimal digit corresponds to four bits; because 8=238=2^3, one octal digit corresponds to three bits. Thus 11010110211010110_2, grouped as 1101 01101101\,0110, becomes D616\mathrm{D6}_{16}. Grouping preserves the value while shortening the written representation. (csapp.cs.cmu.edu)

Binary arithmetic

Binary arithmetic uses the familiar principles of carrying and borrowing, but carries occur at two rather than ten. The elementary addition rules are 0+0=00+0=0, 0+1=10+1=1, and 1+1=1021+1=10_2. In a column containing two 1s, the result digit is 0 and a carry of 1 enters the next column. With an incoming carry, 1+1+1=1121+1+1=11_2. For example,

10112+01102=100012,1011_2+0110_2=10001_2,

which corresponds to 11+6=1711+6=17. Subtraction similarly borrows from the next position, whose value is twice that of the current position. (openstax.org)

Multiplication combines shifted copies of the multiplicand for positions where the multiplier contains 1. Appending a zero multiplies an unsigned binary integer by two; removing its final digit gives the integer quotient on division by two. In fixed-width hardware, however, shifting can discard significant bits. A mathematically valid result may exceed the available representation, producing overflow. (math.mit.edu)

Fractions and infinite expansions

Places to the right of the binary point represent 2−1,2−2,2−3,…2^{-1},2^{-2},2^{-3},\ldots. For example,

0.1012=12+18=58=0.62510.0.101_2=\frac12+\frac18=\frac58=0.625_{10}.

A rational number has a terminating binary expansion exactly when its denominator, after reduction to lowest terms, is a power of two. Other rational numbers have eventually repeating expansions. Decimal 0.10.1, for instance, equals the infinite binary fraction 0.0001100110011…20.0001100110011\ldots_2. (docs.python.org)

Binary expansions can also describe real numbers through infinite digit sequences. As with decimal notation, some values have two expansions: 0.12=0.01111…20.1_2=0.01111\ldots_2. This equality follows because the infinite tail sums to one-half. Finite computer representations cannot retain arbitrary infinite expansions; floating-point arithmetic therefore introduces approximation and rounding for many otherwise simple decimal fractions. (docs.python.org)

Signed numbers and computer encodings

On paper, negative values can be written with a minus sign. Computers commonly encode signed integers using two’s complement. In an nn-bit representation, the highest-order bit has weight −2n−1-2^{n-1}, while the remaining bits retain positive weights. Its range is therefore −2n−1-2^{n-1} through 2n−1−12^{n-1}-1. For eight bits, this is −128-128 through 127127. (cs.cmu.edu)

The negative of a representable positive value is obtained by inverting its bits and adding one. Two’s complement permits closely related circuits to perform signed and unsigned addition. Keeping only nn result bits corresponds to modular arithmetic modulo 2n2^n, although the resulting signed interpretation requires separate attention to overflow. (openstax.org)

Binary notation must also be distinguished from general binary encoding. Bit sequences can encode characters, instructions, or other data rather than ordinary positional numbers. Their meaning is established by an agreed representation, not by the zeros and ones alone. (csapp.cs.cmu.edu)

Historical development and digital logic

Gottfried Wilhelm Leibniz systematically described arithmetic using 0 and 1 in his 1703 essay Explanation of Binary Arithmetic. His treatment included numerical tables and operations, as well as comparisons with Chinese hexagram patterns. (leibniz-translations.com)

Binary representation later became closely connected with Boolean algebra and switching circuits. In his 1937 master’s thesis, Claude Shannon applied Boolean algebra to relay and switching networks. Logic gates manipulate two-valued signals, allowing circuits to implement logical operations and binary arithmetic. Physical states—such as voltage or current levels—represent the digits; they are not themselves abstract numbers. (computerhistory.org)