/************************************************************************* * * * YAP Prolog @(#)YapEval.h 1.2 * * * Yap Prolog was developed at NCCUP - Universidade do Porto * * * * Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * * * ************************************************************************** * * * File: YapEval.h ** Last rev: * mods: ** comments: arithmetical functions info * * * *************************************************************************/ /** @file YapEval.h @defgroup arithmetic Arithmetic in YAP @ingroup builtins + See @ref arithmetic_preds for the predicates that implement arithment + See @ref arithmetic_cmps for the arithmetic comparisons supported in YAP + See @ref arithmetic_operators for what arithmetic operations are supported in YAP YAP supports several different numeric types:
YAP supports integers of word size: 32 bits on 32-bit machines, and 64-bits on 64-bit machines.The engine transprently tags smaller integers are tagged so that they fit in a single word. These are the so called tagged integers.
Larger integers that still fit in a cell are represented in the Prolog goal stack. The difference between these integers and tagged integers should be transparent to the programmer.
When YAP is built using the GNU multiple precision arithmetic library (GMP), integer arithmetic is unbounded, which means that the size of extern integers is only limited by available memory. The type of integer support can be detected using the Prolog flags bounded, min_integer and max_integer. As the use of GMP is default, most of the following descriptions assume unbounded integer arithmetic.
Rational numbers are quotients of two integers. Rational arithmetic is provided if GMP is used. Rational numbers that are returned from is/2 are canonical, which means the denominator _M_ is positive and that the numerator _N_ and _M_ have no common divisors. Rational numbers are introduced in the computation using the rational/1, rationalize/1 or the rdiv/2 (rational division) function.
Floating point numbers are represented using the C-type double. On most today platforms these are 64-bit IEEE-754 floating point numbers. YAP now includes the built-in predicates isinf/1 and to isnan/1 tests.