Rational number is a number that is expressed as a ratio of two integers (hence its name ” rational “). It is written on the basis of a fraction in which the top number (numerator) is divided by the bottom number (denominator).

All integers are rational numbers because they can be divided by 1, which provides a ratio of two integers. Many floating point numbers are also rational numbers since they can be expressed on the basis of fractions. For example, 1.5 is rational since it can be written as 3/2, 6/4, 9/6 or other fraction or two integers. Pi (π) is irrational because it cannot be written in fraction.

A floating point number is rational if it follows any one of the criteria given below:

1. It has a limited number of digits after the decimal point (eg, 5.467)

2. It has an infinitely repeating number mezhu after the decimal point (eg, 2.333333…)

3. It has an infinitely repeating pattern of numbers after the decimal point (eg 3.151515…)
if the numbers repeat after the decimal point infinitely without a pattern, then the number is neither rational or “irrational.” Here below are some 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 quite important that a number is rational or irrational. A rational number is stored as an exact numeric value, while an irrational number has to be estimated.

This number zero (0) is a rational number because it can be written as 0/1, which is the same as 0.

« Back to Wiki Index