[ Reference Manual | Alphabetic Index ]

Arithmetic

Built-ins for arithmetic computations   [more]

Predicates

*(+Number1, +Number2, -Result), -Result is +Number1 * +Number2
Evaluates the product Number1 * Number2 and unifies the resulting value with Result.
+(+Number, -Result), -Result is + +Number
Checks if Number is a number and unifies it with Result.
+(+Number1, +Number2, -Result), -Result is +Number1 + +Number2
Evaluates the sum Number1 + Number2 and unifies the resulting value with Result.
-(+Number, -Result), -Result is - +Number
Unifies the negative of Number with Result.
-(+Number1, +Number2, -Result), -Result is +Number1 - +Number2
Evaluates the difference Number1 - Number2 and unifies the resulting value with Result.
/(+Number1, +Number2, -Result), -Result is +Number1 / +Number2
Evaluates the quotient Number1 / Number2 and unifies the resulting value with Result.
//(+Number1, +Number2, -Result), -Result is +Number1 // +Number2
Evaluates the integer quotient Number1 // Number2 and unifies the resulting value with Result.
/\(+Number1, +Number2, -Result), -Result is +Number1 /\ +Number2
Evaluates the bitwise conjunction Number1 /\ Number2 and unifies the resulting value with Result.
+Expr1 < +Expr2
Succeed if the value of Expr1 is less than the value of Expr2.
<<(+Number1, +Number2, -Result), -Result is +Number1 << +Number2
Shifts Number1 left by Number2 bits and unifies the resulting value with Result.
+Expr1 =:= +Expr2
Succeed if the value of Expr1 is equal to the value of Expr2.
+Expr1 =< +Expr2
Succeed if the value of Expr1 is less than or equal to the value of Expr2.
+Expr1 =\= +Expr2
Succeed if the value of Expr1 is not equal to the value of Expr2.
+Expr1 > +Expr2
Succeed if the value of Expr1 is greater than the value of Expr2.
+Expr1 >= +Expr2
Succeed if the value of Expr1 is greater than or equal to the value of Expr2.
>>(+Number1, +Number2, -Result), -Result is +Number1 >> +Number2
Shifts Number1 right arithmetically by Number2 bits and unifies the resulting value with Result.
\(+Number, -Result), -Result is \ +Number
Evaluates the bitwise complement of Number and unifies the resulting value with Result.
\/(+Number1, +Number2, -Result), -Result is +Number1 \/ +Number2
Evaluates the bitwise disjunction Number1 \/ Number2 and unifies the resulting value with Result.
^(+Number1, +Number2, -Result), -Result is +Number1 ^ +Number2
Evaluates the expression Number1 "to the power of" Number2 and unifies the resulting value with Result.
abs(+Number, -Result), -Result is abs(+Number)
Unifies the absolute value of Number with Result.
acos(+Number, -Result), -Result is acos(+Number)
Evaluates the trigonometric function acos(Number) and unifies the resulting value with Result.
asin(+Number, -Result), -Result is asin(+Number)
Evaluates the trigonometric function asin(Number) and unifies the resulting value with Result.
atan(+Number, -Result), -Result is atan(+Number)
Evaluates the trigonometric function atan(Number) and unifies the resulting value with Result.
atan(+Y, +X, -Result), -Result is atan(+Y, +X)
Computes the arc tangent function of two variables and unifies the resulting value with Result.
between(+From, +To, +Step, -Result)
Generate integer values between From and To with Step increment.
breal(+Number, -Result), -Result is breal(+Number)
Converts Number into a breal number and unifies it with Result.
breal_bounds(+Number, -Min, -Max)
Extracts lower and upper floating point bounds of Number
breal_from_bounds(+Number1, +Number2, -Result), -Result is breal_from_bounds(+Number1, +Number2)
Constructs a bounded real from the given floating point bounds
breal_max(+Number, -Result), -Result is breal_max(+Number)
Extracts the upper floating point bound of Number
breal_min(+Number, -Result), -Result is breal_min(+Number)
Extracts the lower floating point bound of Number
ceiling(+Number, -Result), -Result is ceiling(+Number)
Unifies Result with the least integral value that is greater than or equal to Number and of the same numeric type as Number.
clrbit(+Number, +Index, -Result), -Result is clrbit(+Number, +Index)
Result is Number with the Index'th bit cleared.
copysign(+X, +Y, -Result), -Result is copysign(+X, +Y)
Compose a number from magnitude and sign
cos(+Number, -Result), -Result is cos(+Number)
Evaluates the trigonometric function cos(Number) and unifies the resulting value with Result.
denominator(+Number, -Result), -Result is denominator(+Number)
Extracts the denominator of the rational Number and unifies the resulting integer with Result.
div(+Number1, +Number2, -Result), -Result is +Number1 div +Number2
Evaluates the integer quotient Number1 div Number2 and unifies the resulting value with Result.
eval(+Expression, -Result), -Result is eval(+Expression)
Used to evaluate eval/1 terms in arithmetic expressions.
exp(+Number, -Result), -Result is exp(+Number)
Evaluates the exponential function exp(Number) ("e to the power of Number") and unifies the resulting value with Result.
fix(+Number, -Result), -Result is fix(+Number)
Unifies the integer part of Number with Result (Truncation towards zero).
float(+Number, -Result), -Result is float(+Number)
Converts Number to float and unifies the resulting value with Result.
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.
frandom(-F)
Generates a random floating-point number F in the range <0, 1>
gcd(+Number1, +Number2, -Result), -Result is gcd(+Number1, +Number2)
Unifies Results with the Greatest Common Divisor of Number1 and Number2
gcd(+Number1, +Number2, -U, -V, -GCD)
Unifies GCD with the Greatest Common Divisor of Number1 and Number2, and gives appropriate coefficients U and V for the corresponding Bezout equation
getbit(+Number, +Index, -Result), -Result is getbit(+Number, +Index)
Result is the Index'th bit of Number.
integer(+Number, -Result), -Result is integer(+Number)
Convert an integral number of any type to an integer
?Result is +Expression
Evaluates the arithmetic expression Expression and unifies the resulting value with Result.
lcm(+Number1, +Number2, -Result), -Result is lcm(+Number1, +Number2)
Unifies Results with the Least Common Multiple of Number1 and Number2
ln(+Number, -Result), -Result is ln(+Number)
Evaluates the natural logarithm ln(Number) and unifies the resulting value with Result.
lsb(+Number, -Result), -Result is lsb(+Number)
Result is the index of the least significant nonzero bit
max(+Vector, -Result), -Result is max(+Vector)
Evaluates the the arithmetic expressions in Vector and unifies their maximum with Result.
max(+Number1, +Number2, -Result), -Result is max(+Number1, +Number2)
Unifies the maximum of Number1 and Number2 with Maximum.
min(+Vector, -Result), -Result is min(+Vector)
Evaluates the the arithmetic expressions in Vector and unifies their minimum with Result.
min(+Number1, +Number2, -Result), -Result is min(+Number1, +Number2)
Unifies the minimum of Number1 and Number2 with Minimum.
mod(+Number1, +Number2, -Result), -Result is +Number1 mod +Number2
Evaluates the modulus Number1 mod Number2 and unifies the resulting value with Result.
msb(+Number, -Result), -Result is msb(+Number)
Result is the index of the most significant nonzero bit
nexttoward(+X, +Y, -Result), -Result is nexttoward(+X, +Y)
Next representable number
numerator(+Number, -Result), -Result is numerator(+Number)
Extracts the numerator of the rational Number and unifies the resulting integer with Result.
plus(?Add1, ?Add2, ?Sum)
Succeeds if Sum is the sum of integer arguments Add1 and Add2.
popcount(+Number, -Result), -Result is popcount(+Number)
Result is the number of 1s in Number's binary representation
random(-N)
Generates a random integer N
random(+Limit, -N), -N is random(+Limit)
Generates a random integer N between 0 and Limit-1
rational(+Number, -Result), -Result is rational(+Number)
Converts Number into a rational number and unifies it with Result.
rationalize(+Number, -Result), -Result is rationalize(+Number)
Converts Number into a compact rational number and unifies it with Result.
rem(+Number1, +Number2, -Result), -Result is +Number1 rem +Number2
Evaluates the remainder Number1 rem Number2 and unifies the resulting value with Result.
round(+Number, -Result), -Result is round(+Number)
Rounds Number to the nearest integral value of the same type
seed(+Seed)
Seed the pseudo-random number generator
setbit(+Number, +Index, -Result), -Result is setbit(+Number, +Index)
Result is Number with the Index'th bit set.
sgn(+Number, -Result), -Result is sgn(+Number)
Unifies Result with the sign of Number which is either -1, 0 or 1.
sin(+Number, -Result), -Result is sin(+Number)
Evaluates the trigonometric function sin(Number) and unifies the resulting value with Result.
sqrt(+Number, -Result), -Result is sqrt(+Number)
Evaluates the square root sqrt(Number) and unifies the resulting value with Result.
succ(?X, ?Y)
Successor relation over natural numbers.
sum(+Vector, -Result), -Result is sum(+Vector)
Computes the sum of the elements of Vector, or the scalar product of two vectors
tan(+Number, -Result), -Result is tan(+Number)
Evaluates the trigonometric function tan(Number) and unifies the resulting value with Result.
times(?Factor1, ?Factor2, ?Product)
Succeeds if Product is the result of multiplying integer arguments Factor1 and Factor2.
truncate(+Number, -Result), -Result is truncate(+Number)
Unifies Result with the closest integer value between 0 and Number, and of the same numeric type as Number.
xor(+Number1, +Number2, -Result), -Result is xor(+Number1, +Number2)
Evaluates the bitwise exclusive disjunction Number1 xor Number2 and unifies the resulting value with Result.

Description

See also the User Manual chapter on Arithmetic

See Also

is / 2
Generated from arithmetic.eci on 2026-07-14 10:58