Foundation

Understanding Binary Numbers

A visual introduction to binary conversion, negative numbers in two’s complement, and the basic idea of floating-point representation.

Computers store numbers using bits, but the same number does not always use the same kind of bit pattern. In this lesson, you will first learn how a whole number like 19 becomes binary, then how a negative value like -22 is stored, and finally how real numbers like 3.14 and 0.625 are handled.

This is a foundation lesson, so the main goal is to build intuition. You do not need to memorize every detail. You only need to understand the basic structure and why computers use different formats for different kinds of numbers.

Level
Foundation
Binary Example
19 → 10011
Negative Number Example
-22 → 11101010
Arithmetic Example
45 + (-22) = 23

Quick Facts

Binary

Binary uses only 0 and 1. Each place value is a power of 2, not a power of 10.

Two’s Complement

Computers usually store negative integers by flipping the bits and then adding 1.

Floating Point

Real numbers are often stored using three parts: a sign, an exponent, and a fraction.

Main Goal

Learn how different kinds of numbers become different kinds of binary patterns inside a computer.

Key Idea

A computer does not store numbers the way humans write them on paper. It stores patterns of bits.

The important idea is this: the meaning of a bit pattern depends on the format being used. A whole number, a negative integer, and a decimal value may all need different representations.

Visualization

This animation walks through four connected ideas: converting 19 to binary, converting -22 to two’s complement, introducing floating-point representation with 3.14 and 0.625, and adding 45 + (-22) in binary.

Example 1: Convert 19 to Binary

Step 1: Divide by 2

Repeatedly divide the number by 2 and record each remainder.

19 ÷ 2 = 9  remainder 1
9 ÷ 2  = 4  remainder 1
4 ÷ 2  = 2  remainder 0
2 ÷ 2  = 1  remainder 0
1 ÷ 2  = 0  remainder 1
Step 2: Read Bottom to Top

The remainders are read from bottom to top.

1 0 0 1 1
Binary Result

So the decimal number 19 becomes:

19 = 10011₂
Why It Works

Each digit in binary represents a power of 2: 16, 8, 4, 2, 1. The pattern 10011 means 16 + 2 + 1 = 19.

A good beginner rule: divide by 2, keep the remainders, then read upward.

Example 2: Convert -22 to Two’s Complement

Start with +22

First write positive 22 in 8-bit binary.

22 = 00010110
Flip the Bits

Change every 0 to 1 and every 1 to 0.

00010110 → 11101001
Add 1

After flipping the bits, add 1.

11101001
+      1
--------
11101010
Final Answer

The 8-bit two’s complement form of -22 is:

-22 = 11101010
For many beginner examples, the rule is: write the positive value, flip all bits, then add 1.

Example 3: Floating-Point Representation

What Floating Point Stores

Floating-point numbers are usually broken into three parts: a sign bit, an exponent, and a fraction. This lets computers store many different decimal values efficiently.

Example: 3.14

In the animation, 3.14 is converted to binary approximately, then rewritten in normalized form:

3.14 ≈ 11.0010001111₂
1.10010001111 × 2^1
Cleaner Fraction Example: 0.625

For fractions, multiply by 2 and record the whole-number part each time.

0.625 × 2 = 1.25  → 1
0.25 × 2  = 0.5   → 0
0.5 × 2   = 1.0   → 1

0.625 = 0.101₂
Normalized Form

The binary fraction can then be rewritten in normalized form:

0.101₂ = 1.01 × 2^-1

Half precision layout:
0 | 01110 | 0100000000
At the foundation level, the main idea is not the exact bit count. The main idea is that floating point stores a number using sign + scale + significant bits.

Example 4: Binary Arithmetic with 45 + (-22)

Write 45 in Binary

The positive number is:

45 = 00101101
Write -22 in Two’s Complement

From the earlier section:

-22 = 11101010
Add the Bit Patterns

Now add them the same way you add binary numbers:

  00101101
+ 11101010
-----------
  00010111
Read the Result

The result is:

00010111 = 23

So the arithmetic matches: 45 + (-22) = 23.

One big advantage of two’s complement is that addition still works naturally even when one number is negative.

What Learners Should Notice

Whole Numbers

A value like 19 can be written directly in binary by using powers of 2.

Negative Integers

A value like -22 needs a signed representation such as two’s complement.

Real Numbers

A value like 3.14 or 0.625 needs a format that can handle decimal-style values, such as floating point.

Same Bits, Different Meaning

Computers always store bits, but the format gives those bits meaning.

Common Confusions

“Binary only means counting in 0 and 1”

Binary is more than counting. It is also the language used to store whole numbers, negative integers, and floating-point values.

“Negative numbers just use a minus sign”

Inside a computer, negative integers are usually stored with two’s complement, not with a visible minus symbol.

“3.14 can be stored perfectly”

Some decimal values are only stored approximately in binary floating point. That is normal and expected.

“All bit patterns mean the same thing”

They do not. A bit pattern must be interpreted using the correct representation system.

Outcome

After this lesson, learners should be able to convert a small decimal integer to binary, explain the basic idea of two’s complement for negative integers, describe why floating-point numbers use sign, exponent, and fraction, and follow a simple example of binary addition with a negative value.