Overview

In Prolog, arithmetic is performed by certain built-in predicates, which take arithmetic expressions as their arguments and evaluate them. Arithmetic expressions can evaluate to integers or floating-point numbers (floats).

With release 3 Quintus Prolog has full 32 bit integer arithmetic and full 64 bit double precision floating point arithmetic. The range of integers is -2147483648 (-2^31) to 2147483647 (2^31-1) both inclusive. Arithmetic operations like integer addition and multiplication raise a representation error if there is an overflow.

The range of floating-point numbers is approximately 2.3E-308 to 1.7E+308. Floats are represented by 64 bits and they conform to the IEEE 754 standard. The behavior on floating-point overflow or underflow is machine-dependent.

Chapter summary: The arithmetic operations of evaluation and comparison are implemented in the predicates described in ref-ari-eae and ref-ari-acm. All of them take arguments of the type Expr, which is described in detail in ref-ari-aex.