The Jekejeke Prolog interpreter accepts numbers and internally
represents them as integers, floats or decimals. The
implementation represents floats and decimals as pairs of a
mantissa and a scale. For floats the scale is binary, for decimals
the scale is decimal:
float = mantissa * 2scaleExamples:
decimal = mantissa * 10scale
1.0 = 100.0E-2
0d0.01 = 0d1E-2
0d123.4 = 0d1.234E2
0d1.0 \= 0d100E-2
If an integral value is between -2^31 and 2^31-1 then the Java Integer is used instead of the Java BigInteger. Similarly if a decimal value has scale 0 and a mantissa between -2^63 and 2^63-1 then the Java Long is used instead of the Java BigDecimal. The decimal scale is restricted to 31 bits.
The float mantissa is bounded and approximated to the precision. The small respectively large float binary scale is restricted to 8 bits respectively 11 bits. A negative zero is mapped to a positive zero. A NaN or infinity, irrespective of its sign, is considered outside of the domain and leads to an error.Example:
factorial(X, Y) :- X>0, H is X-1, factorial(H, J), Y is X*J.
?- X is factorial(4).
X = 24
The predicate is/2 can be used to evaluate a term consisting of evaluable functions and number constants. Thanks to bridging an evaluable function can also be defined by ordinary Prolog clauses for the corresponding predicate. The evaluable function will only deliver the first result of the corresponding predicate.
The following built-in predicates are provided for arithmetic domains:
The following Prolog flags for arithmetic domains are provided: