Advanced

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.

Level
Advanced
Real Number Example
5.75
Signed Integer Example
13 + (-5)
Core Models
IEEE 754 & Two’s Complement

Quick Facts

Floating Point

Used for real numbers such as 5.75. Stores a value using a sign, an exponent, and a mantissa.

Two’s Complement

Used for signed integers such as -5. Negative values are formed by inverting bits and adding 1.

Important Difference

Floating point and two’s complement are not the same encoding system. They solve different storage problems.

Main Learning Goal

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

Convert to Binary

The integer part is 5 = 101₂. The fractional part is 0.75 = .11₂.

5.75 = 101.11₂
Normalize

IEEE 754 stores the number in normalized form:

1.0111 × 2²
Exponent

In single precision, the exponent uses a bias of 127. Since the exponent is 2, the stored exponent becomes:

2 + 127 = 129 = 10000001₂
Mantissa

The mantissa stores the significant bits after the leading 1.

01110000000000000000000
Floating point is designed to store a wide range of real numbers efficiently by separating sign, scale, and significant digits.

Floating-Point Result

Putting the three parts together gives the final 32-bit floating-point representation:

0 | 10000001 | 01110000000000000000000

That pattern stores the value 5.75 in IEEE 754 single precision.

Example 2: Storing Signed Integers with Two’s Complement

Positive Value

Start with positive five in 8-bit binary:

+5 = 00000101
Invert the Bits

Flip every bit:

11111010
Add 1

Add one to form the negative value:

-5 = 11111011
Add with 13

Now add the 8-bit form of 13:

  00001101
+ 11111011
-----------
  00001000
The result is 8, which matches the arithmetic: 13 + (-5) = 8.

Why These Two Systems Are Different

Floating Point

Best for real numbers, decimals, and scientific values. Uses sign, exponent, and mantissa to represent a large range of magnitudes.

Two’s Complement

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

“All binary is the same”

Not true. The meaning of a bit pattern depends on the representation system being used.

Floating Point vs Integer

IEEE 754 is for real numbers. Two’s complement is for signed integers. They solve different storage problems.

Mantissa Means “Whole Number Part”

Not exactly. The mantissa stores the significant bits of the normalized value, not simply the digits before the point.

Negative Values Use a Minus Sign Bit Only

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.