[ Arithmetic | Reference Manual | Alphabetic Index ]

floor(+Number, -Result)

-Result is floor(+Number)

Unifies Result with the greatest integral value that is less or equal than Number and of the same numeric type as Number.
Number
A number.
Result
Output: number.

Description

Unifies Result with the greatest integral value that is less or equal than Number and of the same numeric type as Number.

This operation works on all numeric types. The result value is the largest integral value that is smaller that Number (rounding down towards minus infinity).

The result type is the same as the argument type. To convert the type to integer, use integer/2.

This predicate can be used as a function in arithmetic expressions. In coroutining mode, if Number is uninstantiated, the call to floor/2 is delayed until this variable is instantiated.

Modes and Determinism

Exceptions

(4) instantiation fault
Number is not instantiated (non-coroutining mode only).
(24) number expected
Number is not of a numeric type.

Examples

    Result is floor(1.8).		% gives Result = 1.0
    Result is floor(-1.8).		% gives Result = -2.0
    Result is floor(1.0).		% gives Result = 1.0
    Result is floor(-0.0).		% gives Result = -0.0
    Result is floor(5).			% gives Result = 5

See Also

is / 2, ceiling / 2, round / 2, truncate / 2, integer / 2