The idea
Key formulas
Positional value
Loading lessons…
Just a moment, getting everything ready. The first load can take up to a minute.
Discrete maths
Positional notation represents integers and fractions in different bases, while computers encode signed integers and approximate real numbers.
In base , a positional numeral has value , with each digit between 0 and . Binary uses base 2, octal base 8, decimal base 10, and hexadecimal base 16 (digits A through F represent 10 through 15). Since and , groups of three or four binary bits convert directly to octal or hexadecimal.
An unsigned -bit integer ranges from 0 to . Two's complement represents signed integers in bits, with range through . To encode a negative number, complement its positive bit pattern and add one.
IEEE 754 floating point stores a sign, a biased exponent, and a fraction (often called the significand or mantissa field). A normalized binary value has the form . Single precision has 1 sign bit, 8 exponent bits (bias 127), and 23 fraction bits; double precision has 1, 11 (bias 1023), and 52. Many decimal fractions, including 0.1, have repeating binary expansions, so finite precision rounds them. In binary64, the rounded values of 0.1 and 0.2 add to a value slightly above the rounded 0.3; this is representation and rounding error, not a failure of arithmetic.
In common binary64 arithmetic, 0.1 + 0.2 evaluates to approximately 0.30000000000000004, not the stored value of 0.3, because each decimal input is first rounded to a nearby representable binary fraction and the rounded operands are then added.