next up previous contents index
Next: Evaluable Functors for Arithmetic Up: Standard Predicates Previous: Term I/O   Contents   Index


Evaluating Arithmetic Expressions through is/2

As do most Prologs, XSB supports evaluation of arithmetic expressions in two ways. First, XSB supports evaluation of ground arithmetic expressions throught the is/2 operator. Support of comparisons of non-ground arithmetic expressions is provided through the port to XSB of the CLPQR constraint handling interface. In this section we describe how arithmetic expressions can be evaluated through is/2, while the CLPQR interface is described in Volume 2 of this manual.

Before describing is/2 and the expressions that it can evaluate, we note that in Version 2.5 of XSB, integers and floats in XSB are represented using a single word of 32 or 64 bits, depending on the machine architecture. Since type tags constitute part of this word, this means that there may be as little as 28 bits available to represent a floating point number. In addition, evaluation of arithmetic expressions through is/2 does not check for overflow or underflow. As a result, XSB's floating point operations do not conform to IEEE floating point standards, and deviates in this regard from the ISO Prolog standard (see [25] Section 9). We hope to fix these problems in a future release 6.1

All of the evaluable functors describe below throw a type error if their evaluated input is not numeric. We describe below only their behavior on correctly typed input.

is(?Result,+Expression)

is(Result,Expression) is true iff the result of evaluating Expression as a sequence of evaluable functors unifies with Result. As mentioned in Section 3.8.5, is/2 is an inline predicate, so calls to is/2 within compiled code will not be visible during a trace of program execution.



Subsections
next up previous contents index
Next: Evaluable Functors for Arithmetic Up: Standard Predicates Previous: Term I/O   Contents   Index
Luis Fernando P. de Castro 2003-06-27