Rational numbers implement the corresponding mathematical domain, i.e. ratios of two integers (numerator and denominator). ECLiPSe represents rationals in a canonical form where the greatest common divisor of numerator and denominator is 1 and the denominator is positive. Rational constants are written as numerator and denominator separated by an underscore, e.g.
1_3 -30517578125_32768 0_1Rational arithmetic is arbitrarily precise. When the global flag prefer_rationals is set, the system uses rational arithmetic wherever possible. In particular, dividing two integers then yields a precise rational rather than a float result.