Real Numbers: Definition, Types, Examples and Properties
Numbers Fundamentals Proof Computing
Quick answer
Real numbers are all the numbers that sit on the number line. They are the numbers we use every day — integers, fractions, and decimals that terminate or eventually repeat periodically, all called rational numbers — together with numbers such as √2 and π that no fraction can equal, called irrational numbers. The set of real numbers is written ℝ. A real number is rational when its decimal expansion terminates or eventually repeats periodically, and irrational when its decimal expansion is infinite and never periodic.
Key takeaways
- Every point on the number line is a real number, and every real number is a point: ℝ is the number line.
- The number sets nest: ℕ⊂ W⊂ℤ⊂ℚ⊂ℝ, and the irrational numbers are the real numbers outside ℚ.
- A fraction in lowest terms has a terminating decimal expansion exactly when its denominator has no prime factor other than 2 and 5. Otherwise the expansion eventually repeats periodically.
- √2 is irrational, and the proof is short. So are π and e, and for a positive integer n, √n is irrational exactly when n is not a perfect square.
- Between any two real numbers there are infinitely many rational and infinitely many irrational numbers, yet the rationals alone leave gaps that the real numbers fill.
- A computer keeps only a finite binary approximation of a real number, which is why
0.1 + 0.2 == 0.3is False in Python and JavaScript. Compare with a tolerance.
What is a real number?
A real number is any number that can be placed on the number line. Equivalently, it is any number that has a decimal expansion: one that terminates, one that eventually repeats periodically, or one that is infinite and never periodic: 3, -0.5, 1/3=0.333… and √2=1.41421… are all real numbers. The set of all real numbers is written ℝ.
Every time you measure something — the length of a table, the temperature at noon, the time a race took — the answer is a real number.
Another way to say the same thing is geometric. Draw a straight line, mark a point for 0 and another for 1, and every point on the line stands for exactly one real number. The line is the number line. Intuitively it has no gaps; that property is called completeness, and the section on the number line below says exactly what it means.
Real numbers are the numbers used in measurement, in calculus, in physics, and in almost every program that does arithmetic. Knowing how they are organized — which are fractions, which are not, and how a computer stores them — prevents a long list of mistakes, from a wrong exam answer to a wrong bank balance.
A note on notation. In this article the natural numbers ℕ are 1,2,3,… and the whole numbers W are 0,1,2,3,…. Some books count 0 as a natural number, so check the convention when you read elsewhere. The word integer always means a number in ℤ, and decimal expansion means the full list of digits of a number, however long.
Real numbers at a glance
| Fact | Detail |
|---|---|
| Symbol | ℝ |
| What it contains | all rational and all irrational numbers |
| Decimal expansion | terminates, eventually repeats periodically, or is infinite and never periodic |
| Operations | closed under addition, subtraction, multiplication and division (never by 0) |
| Size | uncountably infinite (Cantor, 1874) |
| Built rigorously by | Dedekind and Cantor, both in 1872 |
| Not real numbers | ∞, and √(-1) (a complex number) |
What are the types of real numbers?
The types of real numbers are the natural, whole, integer, rational and irrational numbers. They are built up in layers: each layer contains the one before it and adds numbers the earlier layers could not express.
| Set | Symbol | What it contains | Examples |
|---|---|---|---|
| Natural numbers | ℕ | the counting numbers 1, 2, 3, … | 1, 7, 250 |
| Whole numbers | W | the natural numbers together with 0: 0, 1, 2, 3, … | 0, 3, 12 |
| Integers | ℤ | whole numbers and their negatives | −5, 0, 8 |
| Rational numbers | ℚ | every number p/q with integers p and q≠ 0 | 2/3, −0.75, 4 |
| Irrational numbers | ℝ∖ℚ | real numbers that are not rational | √2, π, e |
| Real numbers | ℝ | all of the above together | everything on the number line |
Every integer is rational, because 5=5/1, and the article on rational numbers shows how fractions are compared, added and simplified. Every rational number is real. And the two big families, rational and irrational, do not overlap: a real number is exactly one of them.
Interactive: where does a number live?
Tap a number to drop it into the diagram of nested number sets and see every set it belongs to.
Not every number is real. The equation x^2=-1 has no real solution, because a real number squared is never negative. Mathematicians add a new number i with i^2=-1 and get the complex numbers ℂ, which contain ℝ — but that is another article.
One trap before you try the next activity. A root sign does not make a number irrational: √(16)=4 is a natural number. And a decimal does not make a number irrational either: 1.4142 terminates, so it is the fraction (14142)/(10000).
Interactive: classify the number
Ten numbers, one at a time: choose the smallest set each one belongs to and get an explanation straight away.
What is a rational number? Fractions and decimals
A rational number is a number that can be written as a fraction p/q of two integers, with q≠ 0. The word comes from ratio. Every rational number can also be written as a decimal, and its decimal expansion always behaves in one of two ways:
- It terminates: 1/8=0.125 and (3)/(40)=0.075.
- It eventually repeats periodically, with one block of digits repeating without end: 1/3=0.333…=0.(3 repeating) and (3)/(11)=0.272727…=0.(27 repeating).
The bar over the digits marks the repeating block. Which of the two happens is decided by the denominator, once the fraction is in lowest terms.
Interactive: fraction to decimal
Type a fraction and see its decimal expansion, whether it ends or repeats, the repeating block, and the prime-factor rule that decides it.
Why must a decimal repeat? Do the long division of p/q. After each digit a remainder is left, and it is always one of 0, 1, …, q-1. If the remainder is ever 0, the decimal terminates. If not, there are only q-1 possible non-zero remainders, so within q steps one of them must come back — and from that moment the digits repeat, because the same remainder leads to the same next digit. This is why the block of 1/7=0.(142857 repeating) is exactly 6 digits long, one less than 7.
How to turn a repeating decimal into a fraction. Follow these steps, shown for x=0.(27 repeating):
- Name the number: let x=0.(27 repeating).
- Multiply by 10^n, where n is the length of the repeating block (here 2, so multiply by 100): 100x=27.(27 repeating).
- Subtract the original number, so the endless tails cancel: 100x-x=27, which is 99x=27.
- Solve and simplify: x=(27)/(99)=(3)/(11).
When some digits do not repeat, as in 0.41(6 repeating), use two shifts: 100x=41.(6 repeating) and 1000x=416.(6 repeating). Subtracting gives 900x=375, so x=(375)/(900)=(5)/(12).
Interactive: repeating decimal to fraction
Enter the digits of a repeating decimal and get the fraction it equals, with the working shown step by step.
Try it: which decimal terminates?
Which of these fractions has a terminating decimal?
- (7)/(20)
- 1/6
- 2/9
- (5)/(14)
Try it: repeating decimal to fraction
Write 0.(36 repeating) as a fraction: multiply by 100, subtract, and simplify. Complete the denominator of the simplest form.
What is an irrational number? (with a proof for √2)
An irrational number is a real number that is not rational: no fraction of two integers equals it. Its decimal expansion is infinite and never periodic. Famous examples:
- √2=1.41421356…, the diagonal of a square with side 1.
- π=3.14159265…, the ratio of a circle's circumference to its diameter.
- e=2.71828182…, the base of natural logarithms, which appears in growth and decay.
- φ=(1+√5)/(2)=1.61803398…, the golden ratio.
There is a simple test for square roots: for a positive integer n, √n is irrational exactly when n is not a perfect square (and when it is, √n is a whole number). Factorize n into primes; if every prime appears an even number of times, n is a perfect square and the root is a whole number. So √(50)=5√2 is irrational, while √(49)=7 is not; simplifying radicals shows how √(50) becomes 5√2, and the article on irrational numbers goes further, into π, e and rational approximations.
Proof that √2 is irrational
The ancient Greeks already knew this, and the argument is still the best first example of a proof by contradiction. Suppose √2=a/b where a and b are positive integers that are coprime, meaning they have no common factor greater than 1 (a fraction in lowest terms). We will show that this is impossible.
- Square both sides: 2=(a^2)/(b^2), so a^2=2b^2.
- So a^2 is even. An odd number squared is odd, so a itself must be even: a=2k for some integer k.
- Substitute: (2k)^2=2b^2, so 4k^2=2b^2 and b^2=2k^2.
- So b^2 is even, and by the same reasoning b is even.
- Now a and b are both even, so they share the factor 2. That contradicts the assumption that they are coprime.
The assumption led to a contradiction, so no such fraction exists: √2 is irrational. ∎
Try it: put the proof in order
Put the steps of the proof that √2 is irrational in the right order.
The same idea of proof does not work for π and e, which are much harder. Euler showed in 1737 that e is irrational, and Lambert showed in 1761 that π is (his paper appeared in 1768). Later Hermite (1873) and Lindemann (1882) proved something stronger: e and π are not even roots of any polynomial with integer coefficients, which is called being transcendental. This is what finally ended the ancient problem of squaring the circle.
Now try the decimal digits yourself. The widget below finds √2 one digit at a time: at each step, choose the largest digit whose square stays at or below 2. You can do this for ever, and the digits never settle into a pattern.
Interactive: close in on √2
Find the decimal digits of the square root of 2 one at a time by choosing each digit and checking its square.
Almost every real number is irrational. The rational numbers can be listed one after another in a sequence (they are countable), but Cantor proved in 1874 that the real numbers cannot (they are uncountable). If you picked a real number between 0 and 1 completely at random, the probability that it is rational would be 0. The irrational numbers are not the exotic ones; the rationals are the thin thread we happen to write down most often.
How are real numbers arranged on the number line?
On the number line, the rational numbers are dense but not complete, while the real numbers are both dense and complete. Two properties of the real numbers sound alike and are not.
Density. A set is dense in the real numbers when every stretch of the line, however short, contains at least one of its members. The rational numbers are dense, and so are the irrational numbers: between any two different real numbers there is another one — in fact infinitely many rational numbers and infinitely many irrational numbers. If a<b are rational, the midpoint (a+b)/(2) is rational and lies between them; and a+(b-a)/(√2) is irrational and also lies between them. There is no "next" real number after 0, however much you zoom in.
Completeness. The rational numbers are dense and still have gaps: the number √2 is missing from ℚ. The rationals 1, 1.4, 1.41, 1.414, … get closer and closer to a point on the line, but no rational number is that point.
"A line with no holes" is the picture; the precise statement is the least upper bound property: every non-empty set of real numbers that has an upper bound has a least upper bound. It fails in ℚ — the set of rational numbers whose square is less than 2 is bounded above, yet has no least upper bound among the rationals — and it holds in ℝ, where that least upper bound is √2. This is what makes the real number line continuous, and what calculus relies on.
Interactive: always another number in between
Pick two numbers and keep taking the midpoint: there is always another rational number between them.
What are the properties of real numbers?
Real numbers obey six field properties: closure, commutativity, associativity, distributivity, identity elements and inverses. For all real numbers a, b and c, they follow these rules, and every algebra manipulation you do rests on them:
| Property | Statement |
|---|---|
| Closure | a+b, a-b and a× b are real; so is a÷ b when b≠ 0 |
| Commutative | a+b=b+a and ab=ba |
| Associative | (a+b)+c=a+(b+c) and (ab)c=a(bc) |
| Distributive | a(b+c)=ab+ac |
| Identity | a+0=a and a×1=a |
| Inverse | a+(-a)=0, and a×1/a=1 when a≠0 |
What happens when rational and irrational numbers are mixed? Let q be a non-zero rational number and i an irrational one.
| Operation | Result | Example |
|---|---|---|
| rational + rational | always rational | 1/2+1/3=5/6 |
| rational + irrational | always irrational | 1+√2 |
| non-zero rational × irrational | always irrational | 3√2 |
| irrational + irrational | either | √2+(-√2)=0 but √2+√3 is irrational |
| irrational × irrational | either | √2×√2=2 but √2×√3=√6 is irrational |
Why is q+i always irrational? Suppose it were a rational number r. Then i=r-q would be a difference of two rationals, which is rational — contradicting that i is irrational.
Try it: true or false?
Decide whether each statement is True or False.
- The sum of two irrational numbers is always irrational.
- √2×√8 is a rational number.
- 0.(9 repeating) is slightly less than 1.
- (π)/(2) is an irrational number.
- Every integer is a rational number.
How do you compare real numbers and write intervals?
To compare real numbers use order, to describe a stretch of the number line use an interval, and to measure distance from zero use absolute value.
Order. Any two real numbers can be compared: exactly one of a<b, a=b, a>b is true. Order is transitive (a<b and b<c give a<c). Adding the same number to both sides of an inequality keeps it; multiplying both sides by a negative number reverses it, so -2x<6 gives x>-3.
Intervals. A stretch of the number line is written as an interval. A square bracket means the end is included, a round bracket means it is not, and ∞ always gets a round bracket because it is not a real number.
| Interval | Meaning | Inequality |
|---|---|---|
| (a,b) | open: both ends left out | a<x<b |
| [a,b] | closed: both ends in | a\le x\le b |
| [a,b) | left end in, right end out | a\le x<b |
| (a,∞) | everything above a | x>a |
| (-∞,b] | everything up to and including b | x\le b |
| (-∞,∞) | the whole line, ℝ | any x |
Absolute value. |x| is the distance from x to 0, so it is never negative: |x|=x if x\ge0 and |x|=-x if x<0. More generally |a-b| is the distance between a and b. The inequality |x|<3 means "within 3 of zero", which is the interval (-3,3).
Interactive: interval builder
Set two endpoints and open or closed ends and see the interval notation, the set-builder form and the number line together.
Try it: an absolute-value inequality
Which interval is the solution of |x|\le 2?
- [-2, 2]
- (-2, 2)
- (-∞, 2]
- [-2, ∞)
Why does 0.1 + 0.2 not equal 0.3 in code?
In code, 0.1 + 0.2 does not equal 0.3 because computers store real numbers as 64-bit binary floating-point numbers (floats for short), and 0.1 cannot be stored exactly. A computer has finite memory, and a real number can need infinitely many digits. So programs store an approximation. Almost all languages use the IEEE 754 binary64 format (IEEE 754-2019; see Goldberg, 1991), called a double or a Python float: 1 sign bit, 11 exponent bits and 52 fraction bits, which gives 53 bits of precision — about 15 to 17 significant decimal digits.
The catch is that the format is binary (see binary numbers for how fractions are written in base 2). The decimal 0.1 is (1)/(10), and 10 has the prime factor 5, so in base 2 the expansion of 0.1 is periodic without end, just as the expansion of 1/3 is in base 10. The computer cannot keep an infinite expansion, so it stores the nearest value the format can represent, and the value actually stored is
0.1000000000000000055511151231257827…
Add two such rounded values and the tiny errors show up:
>>> 0.1 + 0.2 0.30000000000000004 >>> 0.1 + 0.2 == 0.3 False >>> import math >>> math.sqrt(2) ** 2 2.0000000000000004 >>> math.isclose(0.1 + 0.2, 0.3) True
0.1 + 0.2 // 0.30000000000000004 0.1 + 0.2 === 0.3 // false Math.abs(0.1 + 0.2 - 0.3) < Number.EPSILON // true 2 ** 53 + 1 === 2 ** 53 // true: integers lose exactness beyond 2^53
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main() {
printf("%.17f\n", 0.1 + 0.2); // 0.30000000000000004
cout << (0.1 + 0.2 == 0.3) << endl; // 0
printf("%.16f\n", sqrt(2) * sqrt(2)); // 2.0000000000000004
cout << (fabs(0.1 + 0.2 - 0.3) < 1e-9) << endl; // 1: compare with a tolerance
return 0;
}
/* output:
0.30000000000000004
0
2.0000000000000004
1
*/This is not a bug in Python or JavaScript, and it is not rare. It is the behavior of binary floating point everywhere, in every language that uses it. A useful fact follows from it: every number a computer can store as a float is a rational number (a fraction whose denominator is a power of 2). A computer never holds √2 or π — only a nearby rational number.
What to do about it:
| Situation | Better approach |
|---|---|
| Are two results equal? | compare with a tolerance: math.isclose(a, b) in Python, or abs(a - b) < eps |
| Money | store whole cents as integers, or use decimal.Decimal |
| Exact fractions | fractions.Fraction in Python keeps 1/10 + 2/10 exactly 3/10 |
| Very large integers | Python int is exact at any size; use BigInt in JavaScript |
| Summing many numbers | math.fsum reduces accumulated rounding error |
Try it below. The widget calculates both expressions with 64-bit floating point, shows the exact value stored, and checks them the three ways a program might.
Interactive: how a computer stores reals
Compare two expressions the way a computer does, with 64-bit floating point, and see why 0.1 + 0.2 is not exactly 0.3.
Try it: what does Python print?
In Python, what does 0.1 + 0.2 == 0.3 evaluate to?
FalseTrue0.3- an error
What are the common mistakes about real numbers?
The most common mistakes about real numbers are the eight below, each with the correct fact.
| Myth | Reality |
|---|---|
| ❌ "π equals 3.14 or 22/7." | Both are rational approximations. π is irrational. |
| ❌ "A number with a root sign is irrational." | √(16)=4 is rational. For a positive integer n, √n is irrational exactly when n is not a perfect square. |
| ❌ "0.999… is just below 1." | It equals 1 exactly. |
| ❌ "Irrational numbers are rare." | Almost every real number is irrational. |
| ❌ "A long, messy decimal must be irrational." | (1)/(97) repeats only after 96 digits and is rational. What matters is whether it ever repeats. |
| ❌ "0.1 + 0.2 ≠ 0.3 means the computer is broken." | It is how binary floating point works. Compare with a tolerance. |
| ❌ "∞ is a real number." | It is not. It is a symbol for "without bound". |
| ❌ "Every number is real." | √(-1) is not. It is a complex number. |
Practice: test your understanding
These questions mix everything above. A wrong answer costs nothing here: read the hint and try again.
Select all that apply
Choose all the irrational numbers.
- √(49)
- √(50)
- π-3
- 0.(45 repeating)
- (√2)/(√8)
Type the answer
How many digits are in the repeating block of the decimal for 1/7?
Type the fraction
Write 0.(7 repeating) as a fraction in lowest terms.
Summary: real numbers at a glance
- Real numbers ℝ are all the points on the number line: rational plus irrational.
- Rational means a fraction of integers; its decimal expansion terminates or eventually repeats periodically. Irrational means it is not: √2, π, e.
- The chain of sets is ℕ⊂ W⊂ℤ⊂ℚ⊂ℝ.
- A reduced fraction terminates exactly when the denominator has only the primes 2 and 5.
- For a positive integer n, √n is irrational exactly when n is not a perfect square; √2 is irrational by contradiction.
- Rational + irrational is irrational; irrational + irrational can be either.
- The rationals are dense but have gaps; the reals are dense and complete.
- Computers store finite binary approximations, so compare floats with a tolerance and use integers,
FractionorDecimalfor exact work.
Glossary: key terms
- Real number
- A number that corresponds to a point on the number line; every real number is either rational or irrational.
- Rational number
- A number that can be written as a fraction of two integers with a non-zero denominator; its decimal expansion terminates or eventually repeats periodically.
- Irrational number
- A real number that cannot be written as a fraction of two integers; its decimal expansion is infinite and never periodic.
- Integer
- A number in the set ℤ: a whole number or its negative, …, −2, −1, 0, 1, 2, ….
- Natural number
- A counting number 1, 2, 3, …; some books also include 0.
- Whole number
- A natural number or zero: 0, 1, 2, 3, ….
- Terminating decimal
- A decimal with finitely many digits after the point, such as 0.125.
- Repeating decimal
- A decimal expansion that eventually repeats periodically: from some digit onward a block of digits repeats without end, such as 0.272727….
- Transcendental number
- A real number that is not a root of any non-zero polynomial with integer coefficients, such as π and e.
- Floating-point number
- The approximation of a real number that a computer stores, usually a 64-bit binary value with about 15 to 17 significant decimal digits.
- Interval
- An unbroken stretch of the real number line, written with brackets, such as [a, b).
- Dense set
- A set is dense in the real numbers when every stretch of the number line, however short, contains at least one of its members; the rational and the irrational numbers are both dense.
- Completeness
- The property that every non-empty set of real numbers with an upper bound has a least upper bound, which means the real number line has no gaps.
- Absolute value
- The distance from a number to 0 on the number line, written |x|.
Frequently asked questions
What is a real number?
A real number is any number that corresponds to a point on the number line. It can be written as a decimal, finite or infinite. Real numbers include integers, fractions, terminating and repeating decimals, and irrational numbers such as √2 and π.
What is the difference between rational and irrational numbers?
A rational number can be written as a fraction of two integers, and its decimal expansion terminates or eventually repeats periodically. An irrational number cannot be written that way, and its decimal expansion is infinite and never periodic. Every real number is exactly one of the two.
Is zero a real number? Is it rational?
Yes to both. Zero is a real number, an integer and a whole number, and it is rational because 0 = 0/1. Whether zero counts as a natural number depends on the convention: Indonesian school books say no, many international books say yes.
Is √2 a rational number?
No. √2 is irrational. If it were a fraction a/b in lowest terms, squaring would give a² = 2b², which forces both a and b to be even, contradicting lowest terms. The ancient Greeks knew this proof.
Is π rational?
No. π is irrational, which Johann Lambert proved in 1761, and it is even transcendental, which Ferdinand von Lindemann proved in 1882. The values 3.14 and 22/7 are only rational approximations of π.
Is 0.999… equal to 1?
Yes, exactly. If x = 0.999…, then 10x = 9.999…, and subtracting gives 9x = 9, so x = 1. The two decimals are different spellings of the same real number.
Is infinity a real number?
No. Infinity is not a real number; it is a symbol meaning "without bound". That is why interval notation always puts a round bracket next to ∞ and −∞.
How many real numbers are there?
Infinitely many, and in a stronger sense than the integers. The integers and the rational numbers can be listed in a sequence, but Georg Cantor proved in 1874 that the real numbers cannot. There are uncountably many of them, and almost all of them are irrational.
Why does 0.1 + 0.2 not equal 0.3 on a computer?
Computers store numbers in binary floating point, and 0.1 has an infinite periodic expansion in binary, so it is stored as the nearest representable value. The stored 0.1 plus the stored 0.2 comes out as 0.30000000000000004, which differs from the stored 0.3. Compare floats with a tolerance instead of using equality.
What are examples of real numbers?
Examples of real numbers include the integer −3, the fraction 2/3, the terminating decimal 0.75, the repeating decimal 0.333…, and the irrational numbers √2, π and e. Every point on the number line is a real number.
What are the properties of real numbers?
Real numbers are closed under addition, subtraction, multiplication and division by a non-zero number, and they are commutative, associative and distributive. They have the identities 0 and 1, additive and multiplicative inverses, and an order in which any two numbers can be compared.
Are all integers real numbers?
Yes. Every integer n is a rational number because n = n/1, and every rational number is a real number. The sets nest: natural numbers, whole numbers, integers, rational numbers and real numbers, each contained in the next.
What is not a real number?
Infinity is not a real number, and neither is the square root of −1, which is an imaginary number belonging to the complex numbers. Division by zero is undefined, so 1/0 is not a real number either.
What is the symbol for real numbers?
The set of real numbers is written ℝ, a blackboard-bold capital R, or \mathbb{R} in LaTeX. Related symbols are ℚ for rational numbers, ℤ for integers and ℕ for natural numbers.
References
- Walter Rudin (1976). Principles of Mathematical Analysis. McGraw-Hill (3rd ed.).
- John Stillwell (2013). The Real Numbers: An Introduction to Set Theory and Analysis. Springer.
- Ivan Niven (1956). Irrational Numbers. Mathematical Association of America (Carus Mathematical Monographs).
- David Goldberg (1991). What Every Computer Scientist Should Know About Floating-Point Arithmetic. ACM Computing Surveys 23(1), 5–48.
- IEEE (2019). IEEE Standard for Floating-Point Arithmetic (IEEE 754-2019). Institute of Electrical and Electronics Engineers.
- Georg Cantor (1874). Über eine Eigenschaft des Inbegriffes aller reellen algebraischen Zahlen. Journal für die reine und angewandte Mathematik 77, 258–262.
Related articles
- Rational Numbers: Fractions, Operations, Decimals and Percent: Rational numbers explained: fractions, equivalent forms, comparing, the four operations, mixed numbers, decimals and percent, with worked examples and practice.
- Irrational Numbers: Definition, Examples, Proofs and Approximations: Irrational numbers explained: why √2 is irrational, which roots are, sums and products, π, e, transcendental numbers and fraction approximations, with practice.
- Integers: Number Line, Operations, Divisibility, GCD and LCM: Integers explained: the number line, adding and multiplying negatives, divisibility, primes, GCD and LCM, and remainders, with worked examples and practice.
- Exponents and Radicals: Laws, Rules, Examples and Practice: Exponents and radicals explained: the five laws, zero, negative and fractional exponents, simplifying roots, rationalizing and scientific notation, with practice.