This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)
 Documentation / Mathematica / Built-in Functions / Numerical Computation / Number Representation  /
Rational

  • Rational is the head used for rational numbers.
  • You can enter a rational number in the form n / m.
  • The pattern object _Rational can be used to stand for a rational number. It cannot stand for a single integer.
  • You have to use Numerator and Denominator to extract parts of Rational numbers.
  • See the Mathematica book: Section 3.1.1.
  • See also: Integer, Numerator, Denominator.

    Further Examples

    Fractions are represented internally without either a fraction bar or the slash character.

    In[1]:=

    Out[1]=

    Therefore the first pattern won't work to identify a fraction.

    In[2]:=

    Out[2]=