A binary representation writes a number in positional notation with radix two and binary digits zero and one. To the left of the binary point the place values are ; to its right they are . For example,
Binary notation changes the numeral, not the underlying number. The same value is in decimal. A finite binary fraction represents a dyadic rational, while an infinite binary expansion can represent any real number in the unit interval. Storing a finite binary string additionally requires an interpretation such as unsigned interpretation or two's complement.
After adding least-significant binary digits, the numerical sum of the two processed input suffixes equals the written result digits plus , with . Initially both suffixes are empty. For the next column, write and pass to the next column. Multiplying these column quantities by preserves the equation. After all columns, the remaining carry supplies the extra leading digit, proving correctness without converting either full input to a machine integer.
For an -bit binary string , the unsigned interpretation assigns positive positional weights to its bits. Its values range from zero to . The same stored bits have two's complement value , so interpreting a machine word is a separate choice from storing its bits.
For a positive integer , its bit length is the number of binary digits in its usual representation:
Equivalently, is the unique positive integer satisfying . For example, has bit length four, and has bit length four too. The inequalities provide an exact characterization without a floating-point logarithm.
Many integer programming interfaces define the bit length of zero as zero. That convention counts no significant one-bit; it differs from the written binary numeral , which has one character. A fixed-width machine word can also contain leading zero bits that do not contribute to the value's bit length.
Every real number has a binary expansion
For , construct it by repeated doubling. Set , then and , using the floor function. Each remainder stays in , and induction gives
The remaining error is less than , so the finite partial sums converge to . For , choose every binary digit equal to one and use the geometric series.
Figure 1.
Successive binary digits refine an interval around
. Each blue interval runs from the th partial sum to . Filled left endpoints are included and open right endpoints are excluded. The red line marks ; the labels show its successive binary prefixes. Each new digit halves the remaining interval's length. Details.
An expansion need not be unique: . For , this ambiguity occurs precisely at the dyadic rationals, through a terminating expansion and an alternative ending in ones. At the endpoints, the displayed purely fractional form uses all zeros for zero and all ones for one. A general nonnegative real number is represented by adding the finite binary representation of its floor to an expansion of its fractional part; a negative real number is handled by a separate sign. In that broader notation, too.
A base-two positional fraction with a binary point separating nonnegative and negative powers of two. For example, . A finite expansion is a dyadic rational: with fractional places, its value is an integer divided by . Conversely, any nonnegative reduced fraction whose denominator is a power of two has a finite binary expansion. Leading integer zeroes and trailing fractional zeroes do not change its value.
A representation with and only finitely many nonzero coefficients. If counts these representations, then , , and for . The integer parity of determines whether the coefficient of must be 1 or may be 0 or 2.
A dyadic rational is a rational number of the form with an integer and a nonnegative integer . Examples are , , zero and every integer. In lowest terms, its denominator is a power of two, so its magnitude has a finite binary expansion.
A positive dyadic rational also has a binary representation ending in infinitely many ones. Replacing the last nonzero binary digit by zero and filling all lower places with ones preserves the value, because
For example, . Zero has no second nonnegative expansion of this type. The same ambiguity applies to the magnitude of a negative dyadic rational, with its sign kept separately.

Articles by others on the same topic (1)

A binary number is a number expressed in the base-2 numeral system, which uses only two digits: 0 and 1. In contrast to the decimal system (base-10), which uses ten digits (0-9), binary is the foundation of digital computing and electronic systems. Each digit in a binary number is referred to as a "bit.