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.
Quick Facts
Binary uses only 0 and 1. Each place value is a power of 2, not a power of 10.
Computers usually store negative integers by flipping the bits and then adding 1.
Real numbers are often stored using three parts: a sign, an exponent, and a fraction.
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
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 1The remainders are read from bottom to top.
1 0 0 1 1So the decimal number 19 becomes:
19 = 10011₂Each digit in binary represents a power of 2: 16, 8, 4, 2, 1. The pattern 10011 means 16 + 2 + 1 = 19.
Example 2: Convert -22 to Two’s Complement
First write positive 22 in 8-bit binary.
22 = 00010110Change every 0 to 1 and every 1 to 0.
00010110 → 11101001After flipping the bits, add 1.
11101001
+ 1
--------
11101010The 8-bit two’s complement form of -22 is:
-22 = 11101010Example 3: Floating-Point Representation
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.
In the animation, 3.14 is converted to binary approximately, then rewritten in normalized form:
3.14 ≈ 11.0010001111₂
1.10010001111 × 2^1For 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₂The binary fraction can then be rewritten in normalized form:
0.101₂ = 1.01 × 2^-1
Half precision layout:
0 | 01110 | 0100000000Example 4: Binary Arithmetic with 45 + (-22)
The positive number is:
45 = 00101101From the earlier section:
-22 = 11101010Now add them the same way you add binary numbers:
00101101
+ 11101010
-----------
00010111The result is:
00010111 = 23So the arithmetic matches: 45 + (-22) = 23.
What Learners Should Notice
A value like 19 can be written directly in binary by using powers of 2.
A value like -22 needs a signed representation such as two’s complement.
A value like 3.14 or 0.625 needs a format that can handle decimal-style values, such as floating point.
Computers always store bits, but the format gives those bits meaning.
Common Confusions
Binary is more than counting. It is also the language used to store whole numbers, negative integers, and floating-point values.
Inside a computer, negative integers are usually stored with two’s complement, not with a visible minus symbol.
Some decimal values are only stored approximately in binary floating point. That is normal and expected.
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.