truncate(@number) [ISO]

This arithmetic predicate rounds it's argument by removing the fractional part, i.e. it rounds towards zero. This predicate attempts to convert the result value to an integer.

see also: arithmetic in Prolog is/2

Examples
X is truncate(1.46). succeeds, X is 1
X is truncate(-2.4). succeeds, X is -2

 

Exceptions
the value of it's argument is smaller than 0 an evaluation_error(negative, A) exception is thrown
The floating point argument or result exceeds the floating point range an evaluation_error(float_overflow) exception is thrown
The integer argument result exceeds the integer range an evaluation_error(int_overflow) exception is thrown

 

 

info@trinc-prolog.com