Rational

From HaskellWiki
Revision as of 08:48, 11 May 2015 by Fylwind (talk | contribs) (add Rational stub)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Values of type Rational represent rational numbers exactly as the ratio of two Integers. Applying toRational to an Integral number n will produce the rational number n % 1; applying toRational to a Real number will produce its rational value (or its closest approximation).

One can also construct Rational values explicitly using the (%) operator. For example, the fraction 2/3 is constructed using 2 % 3.