next up previous index
Next: Floating Point Numbers Up: Numeric Types and Previous: Integers

Rationals

    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 underscoregif, e.g.

	1_3  -30517578125_32768  0_1
Rational 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.



Micha Meier
Mon Mar 4 12:11:45 MET 1996