Rational Number Definition
A rational number is any number that can be expressed as a ratio of two integers (hence the name “rational”). It can be written as a fraction in which the the top number (numerator) is divided by the bottom number (denominator).
All integers are rational numbers since they can be divided by 1, which produces a ratio of two integers. Many floating point numbers are also rational numbers since they can be expressed as fractions. For example, 1.5 is rational since it can be written as 3/2, 6/4, 9/6 or another fraction or two integers. Pi (π) is irrational since it cannot be written as a fraction.
A floating point number is rational if it meets one of the following criteria:
- it has a limited number of digits after the decimal point (e.g., 5.4321)
- it has an infinitely repeating number after the decimal point (e.g., 2.333333…)
- it has an infinitely repeating pattern of numbers after the decimal point (e.g. 3.151515…)
If the numbers after the decimal point repeat infinitely with no pattern, the number is not rational or “irrational.” Below are examples of rational and irrational numbers.
- 1 – rational
- 0.5 – rational
- 2.0 – rational
- √2 – irrational
- 3.14 – rational
- π (3.14159265359…) – irrational
- √4 – rational
- √5 – irrational
- 16/9 – rational
- 1,000,000.0000001 – rational
In computer science, it is significant if a number is rational or irrational. A rational number can be stored as an exact numeric value, while an irrational number must be estimated.
NOTE: The number zero (0) is a rational number because it can be written as 0/1, which equals 0.