projog

4.1. abs - returns the absolute value of a numeric argument.

Examples

?- X is abs(-1).
X = 1

yes

?- X is abs(1).
X = 1

yes

?- X is abs(0).
X = 0

yes

?- X is abs(43.138).
X = 43.138

yes

?- X is abs(-832.24).
X = 832.24

yes

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

yes

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

yes

Note: As this functionality is implemented using java.lang.Math.abs(), when called with an integer argument that is equal to the value of java.lang.Long.MIN_VALUE (i.e. the most negative representable long value) the result is that same value, which is negative.

?- X is abs(-9223372036854775808).
X = -9223372036854775808

yes