[ Reference Manual | Alphabetic Index ]

# Arithmetic

Built-ins for arithmetic computations [more]

## Predicates

> *(+Number1, +Number2, -Result)
>   Evaluates the product Number1 * Number2 and unifies the resulting value with Result.
> +(+Number, -Result)
>   Checks if Number is a number and unifies it with Result.
> +(+Number1, +Number2, -Result)
>   Evaluates the sum Number1 + Number2 and unifies the resulting value with Result.
> -(+Number, -Result)
>   Unifies the negative of Number with Result.
> -(+Number1, +Number2, -Result)
>   Evaluates the difference Number1 - Number2 and unifies the resulting value with Result.
> /(+Number1, +Number2, -Result)
>   Evaluates the quotient Number1 / Number2 and unifies the resulting value with Result.
> //(+Number1, +Number2, -Result)
>   Evaluates the integer quotient Number1 // Number2 and unifies the resulting value with Result.
> /\(+Number1, +Number2, -Result)
>   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)
>   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)
>   Shifts Number1 right arithmetically by Number2 bits and unifies the resulting value with Result.
> \(+Number, -Result)
>   Evaluates the bitwise complement of Number and unifies the resulting value with Result.
> \/(+Number1, +Number2, -Result)
>   Evaluates the bitwise disjunction Number1 \/ Number2 and unifies the resulting value with Result.
> ^(+Number1, +Number2, -Result)
>   Evaluates the expression Number1 "to the power of" Number2 and unifies the resulting value with Result.
> abs(+Number, -Result)
>   Unifies the absolute value of Number with Result.
> acos(+Number, -Result)
>   Evaluates the trigonometric function acos(Number) and unifies the resulting value with Result.
> asin(+Number, -Result)
>   Evaluates the trigonometric function asin(Number) and unifies the resulting value with Result.
> atan(+Number, -Result)
>   Evaluates the trigonometric function atan(Number) and unifies the resulting value with Result.
> atan(+Y, +X, -Result)
>   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)
>   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(+Lo, +Hi, -Result)
>   Constructs a bounded real from the given floating point bounds
> breal_max(+Number, -Result)
>   Extracts the upper floating point bound of Number
> breal_min(+Number, -Result)
>   Extracts the lower floating point bound of Number
> ceiling(+Number, -Result)
>   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 Number with the Index'th bit cleared.
> copysign(+X, +Y, -Result)
>   Compose a number from magnitude and sign
> cos(+Number, -Result)
>   Evaluates the trigonometric function cos(Number) and unifies the resulting value with Result.
> denominator(+Number, -Result)
>   Extracts the denominator of the rational Number and unifies the resulting integer with Result.
> div(+Number1, +Number2, -Result)
>   Evaluates the integer quotient Number1 div Number2 and unifies the resulting value with Result.
> eval(+Expression, -Result)
>   Used to evaluate eval/1 terms in arithmetic expressions.
> exp(+Number, -Result)
>   Evaluates the exponential function exp(Number) ("e to the power of Number") and unifies the resulting value with Result.
> fix(+Number, -Result)
>   Unifies the integer part of Number with Result (Truncation towards zero).
> float(+Number, -Result)
>   Converts Number to float and unifies the resulting value with Result.
> floor(+Number, -Result)
>   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)
>   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 the Index'th bit of Number.
> integer(+Number, -Result)
>   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)
>   Unifies Results with the Least Common Multiple of Number1 and Number2
> ln(+Number, -Result)
>   Evaluates the natural logarithm ln(Number) and unifies the resulting value with Result.
> max(+Vector, -Result)
>   Evaluates the the arithmetic expressions in Vector and unifies their maximum with Result.
> max(+Number1, +Number2, -Maximum)
>   Unifies the maximum of Number1 and Number2 with Maximum.
> min(+Vector, -Result)
>   Evaluates the the arithmetic expressions in Vector and unifies their minimum with Result.
> min(+Number1, +Number2, -Minimum)
>   Unifies the minimum of Number1 and Number2 with Minimum.
> mod(+Number1, +Number2, -Result)
>   Evaluates the modulus Number1 mod Number2 and unifies the resulting value with Result.
> nexttoward(+X, +Y, -Result)
>   Next representable number
> numerator(+Number, -Result)
>   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.
> 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)
>   Converts Number into a rational number and unifies it with Result.
> rationalize(+Number, -Result)
>   Converts Number into a compact rational number and unifies it with Result.
> rem(+Number1, +Number2, -Result)
>   Evaluates the remainder Number1 rem Number2 and unifies the resulting value with Result.
> round(+Number, -Result)
>   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 Number with the Index'th bit set.
> sgn(+Number, -Result)
>   Unifies Result with the sign of Number which is either -1, 0 or 1.
> sin(+Number, -Result)
>   Evaluates the trigonometric function sin(Number) and unifies the resulting value with Result.
> sqrt(+Number, -Result)
>   Evaluates the square root sqrt(Number) and unifies the resulting value with Result.
> succ(?X, ?Y)
>   Successor relation over natural numbers.
> sum(+Vector, -Result)
>   Computes the sum of the elements of Vector, or the scalar product of two vectors
> tan(+Number, -Result)
>   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)
>   Unifies Result with the closest integer value between 0 and Number, and of the same numeric type as Number.
> xor(+Number1, +Number2, -Result)
>   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 2022-09-03 14:26