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

breal(+Number, ?Result)

Converts Number into a breal number and unifies it with Result.
Number
A number.
Result
A variable or bounded real number.

Description

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

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
Result is a number but not of type breal.
(24) number expected
Number is not of a numeric type.
(24) number expected
Result is neither a number nor a variable.

Examples

Success:
    ?- breal(25, X).
    X = 25.0__25.0

    ?- breal(1.5, X).
    X = 1.5__1.5

    ?- breal(3_4, X).
    X = 0.74999999999999989__0.75000000000000011

    ?- breal(1.0__1.01, X).
    X = 1.0__1.01

Fail:
    ?- breal(1.0, 1.0__1.0).
    No (0.00s cpu)

Error:
    ?- breal(A, X).
    instantiation fault in breal(A, X)

    ?- breal(3, 3).
    type error in breal(3, 3)

    ?- breal(1, r).
    number expected in breal(1, r)

    ?- breal(4 + 2, X).
    number expected in breal(4 + 2, X)

See Also

fix / 2, float / 2, rational / 2, is / 2, breal_min / 2, breal_max / 2, breal_bounds / 3, breal_from_bounds / 3, breal / 1