Rational Numbers
(Redirected from Rationals)
Rational numbers are a fraction of two integers. This can get you very, very far. Every number with a decimal point--even ones that repeat--are actually rational numbers.
Python has the Decimal type to handle rational numbers. You should learn to use it and love it.
Lisp has rational numbers built-in. It is expressed as a literal with a /
in the middle, eg, 57/35
.
Sometimes rational numbers won't cut it, like when you need to represent <math>\pi</math> exactly. In that case, you need to use a real number.
Sometimes rational numbers are overkill--you really don't need all that precision. In that case, use a float.