Arithmetic functions are terms which are evaluated by the arithmetic predicates described above. SWI-Prolog tries to hide the difference between integer arithmetic and floating point arithmetic from the Prolog user. Arithmetic is done as integer arithmetic as long as possible and converted to floating point arithmetic whenever one of the arguments or the combination of them requires it. If a function returns a floating point value which is whole it is automatically transformed into an integer. There are three types of arguments to functions:

In case integer addition, subtraction and multiplication would lead to an integer overflow the operands are automatically converted to floating point numbers. The floating point functions ( sin/1, exp/1, etc.) form a direct interface to the corresponding C library functions used to compile SWI-Prolog. Please refer to the C library documentation for details on percision, error handling, etc.
- +Expr
+ +Expr2
- +Expr2
* +Expr2
/ +Expr2
(remainder of division).
// +IntExpr2
(integer division).
evaluates to the ASCII value of the letter a (97). This option is available for compatibility only. It will not work if `style_check(+string)' is active as "a" will then be tranformed into a string object. The recommended way to specify the ASCII value of the letter `a' is 0'a .
.
The seed of this random generator is determined by the system clock when
SWI-Prolog was started.
>> +IntExpr
<< +IntExpr
\/ +IntExpr
/\ +IntExpr
\ +IntExpr
. Expr is the angle in radials.
. Expr is the angle in radials.
. Expr is the angle in radials.
. Result is the angle in radials.
. Result is the angle in radials.
. Result is the angle in radials.
. Result is the
angle in radials. The return value is in the range
.
Used to convert between rectangular and polar coordinate system.
^ +Expr2
(3.141593).