How Computers Store Values
A visual lesson on IEEE 754 single precision for real numbers and 8-bit two’s complement for signed integers.
Computers store values as patterns of bits, but not every kind of value uses the same representation. In this lesson, you will see two important systems: floating point for real numbers like 5.75, and two’s complement for signed integers like -5.
The goal is not just to memorize bit patterns. The goal is to understand why different types of numbers are stored differently, and how to read the structure behind those binary patterns.
Quick Facts
Used for real numbers such as 5.75. Stores a value using a sign, an exponent, and a mantissa.
Used for signed integers such as -5. Negative values are formed by inverting bits and adding 1.
Floating point and two’s complement are not the same encoding system. They solve different storage problems.
Learn how a decimal value becomes a structured binary representation that a computer can store and use.
Key Idea
A computer does not “understand” values the way humans write them. It stores bit patterns, and the meaning of those bit patterns depends on the chosen format.
In this lesson, the same binary language is used in two different ways: one for approximate real numbers and one for exact signed integers.
Example 1: Storing 5.75 as Floating Point
The integer part is 5 = 101₂. The fractional part is 0.75 = .11₂.
5.75 = 101.11₂IEEE 754 stores the number in normalized form:
1.0111 × 2²In single precision, the exponent uses a bias of 127. Since the exponent is 2, the stored exponent becomes:
2 + 127 = 129 = 10000001₂The mantissa stores the significant bits after the leading 1.
01110000000000000000000Floating-Point Result
Putting the three parts together gives the final 32-bit floating-point representation:
0 | 10000001 | 01110000000000000000000That pattern stores the value 5.75 in IEEE 754 single precision.
Example 2: Storing Signed Integers with Two’s Complement
Start with positive five in 8-bit binary:
+5 = 00000101Flip every bit:
11111010Add one to form the negative value:
-5 = 11111011Now add the 8-bit form of 13:
00001101
+ 11111011
-----------
00001000Why These Two Systems Are Different
Best for real numbers, decimals, and scientific values. Uses sign, exponent, and mantissa to represent a large range of magnitudes.
Best for signed integers. Keeps arithmetic efficient and makes addition work naturally in binary hardware.
Visualization
This animation walks through two examples: storing 5.75 using IEEE 754 single precision, and evaluating 13 + (-5) using 8-bit two’s complement.
Common Confusions
Not true. The meaning of a bit pattern depends on the representation system being used.
IEEE 754 is for real numbers. Two’s complement is for signed integers. They solve different storage problems.
Not exactly. The mantissa stores the significant bits of the normalized value, not simply the digits before the point.
In two’s complement, a negative integer is not made by just adding a sign symbol. The entire bit pattern changes.
Outcome
After this lesson, learners should be able to explain why computers use different binary formats for different kinds of values, convert a simple decimal to normalized floating-point form, and describe how two’s complement stores signed integers.