[ Arithmetic | The ECLiPSe Built-In Predicates | Reference Manual | Alphabetic Index ]

numerator(+Number, ?Result)

Extracts the numerator of the rational Number and unifies the resulting integer with Result.
+Number
An integer or rational number.
?Result
A variable or integer.

Description

This predicate is used by the ECLiPSe compiler to expand evaluable arithmetic expressions. So the call to numerator(Number, Result) is equivalent to
    Result is numerator(Number)
which should be preferred.

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

Fail Conditions

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

Resatisfiable

No

Exceptions

(4) instantiation fault
Number is not instantiated (non-coroutining mode only).
(5) type error
Number is a float or breal.
(5) type error
Result is a number but not an integer.
(24) number expected
Number is not of a numeric type.
(24) number expected
Result is neither a number nor a variable.

Examples

Success:
      numerator(3_4, 3).
      numerator(9_12, 3).
      numerator(-3_4, -3).
      numerator(25, 25).
Fail:
      numerator(3_4, 4).
Error:
      numerator(A, 3).                     (Error 4).
      numerator(3.1, 3).                   (Error 5).
      numerator(3_4, 3_1).                 (Error 5).
      numerator(3_4, r).                   (Error 24).
      numerator(1_3 + 3_4, 13).            (Error 24).



See Also

is / 2, denominator / 2, rational / 2