projog

4.16. integer(X) - round X to the nearest integer value.

Examples

?- X is integer(7.0).
X = 7

yes

?- X is integer(7.1).
X = 7

yes

?- X is integer(7.2).
X = 7

yes

?- X is integer(7.3).
X = 7

yes

?- X is integer(7.4).
X = 7

yes

?- X is integer(7.49999).
X = 7

yes

?- X is integer(7.5).
X = 8

yes

?- X is integer(7.50001).
X = 8

yes

?- X is integer(7.6).
X = 8

yes

?- X is integer(7.7).
X = 8

yes

?- X is integer(7.8).
X = 8

yes

?- X is integer(7.9).
X = 8

yes

?- X is integer(8.0).
X = 8

yes

?- X is integer(-7.0).
X = -7

yes

?- X is integer(-7.1).
X = -7

yes

?- X is integer(-7.2).
X = -7

yes

?- X is integer(-7.3).
X = -7

yes

?- X is integer(-7.4).
X = -7

yes

?- X is integer(-7.49999).
X = -7

yes

Note: in some Prolog implementations the result of "integer(-7.5)" would be -8

?- X is integer(-7.5).
X = -7

yes

?- X is integer(-7.50001).
X = -8

yes

?- X is integer(-7.6).
X = -8

yes

?- X is integer(-7.7).
X = -8

yes

?- X is integer(-7.8).
X = -8

yes

?- X is integer(-7.9).
X = -8

yes

?- X is integer(-8.0).
X = -8

yes

?- X is integer(1.25+6.25).
X = 8

yes

?- X is integer(1.25+6.24).
X = 7

yes

?- X is integer(0.0).
X = 0

yes

?- X is integer(7).
X = 7

yes

?- X is integer(-7).
X = -7

yes

?- X is integer(9223372036854775806).
X = 9223372036854775806

yes

?- X is integer(-9223372036854775807).
X = -9223372036854775807

yes