A rational number is a number that can be expressed as the ratio between two integers, usually written as a / b, where the denominator (here b) is not equal to zero. Rational numbers are commonly called "fractions".
Mathematically we may define them as an ordered pair of integers (a, b), with b not equal to zero. We can define addition and multiplication upon these pairs with the following rules:
- (a, b) + (c, d) = (a * d + b *c, b * d)
- (a, b) * (c, d) = (a * c, b * d)
To conform to our expectation that 2/4 = 1/2, we define an equivalence relation ~ upon these pairs with the following rule:
- (a, b) ~ (c, d) if, and only if, a * d = b * c.