
rational(+Number, ?Result)

   Converts Number into a rational number and unifies it with Result.



Arguments
   +Number             A number.
   ?Result             A variable or rational number.

Type
   Arithmetic

Description
   This predicate is used by the ECLiPSe compiler to expand evaluable
   arithmetic expressions.  So the call to rational(Number, Result) is
   equivalent to

    Result is rational(Number)

    which should be preferred.

   In coroutining mode, if Number is a free variable, the call to
   rational/2 is delayed until this variable is instantiated.




Resatisfiable
      No

Fail Conditions
      Fails if the result of the evaluation does not unify with Result.



Exceptions
     4 --- Number is not instantiated (non-coroutining mode only).
     5 --- Result is a number but not of type rational.
    24 --- Number is not of a numeric type.
    24 --- Result is neither a number nor a variable.

Examples
   
Success:
      rational(25, 25_1).
      rational(1.5, 3_2).
      rational(3_4,3_4).
      rational(9_12,3_4).
      rational(-6, Result).      (gives Result = -6_1)
Fail:
      rational(1, 2_1).
Error:
      rational(A, 1_3).                   (Error 4).
      rational(3, 3).                     (Error 5).
      rational(1, r).                     (Error 24).
      rational(4 + 2, 6_1).               (Error 24).





See Also
   is / 2
