**compatibility**

`1r3`

. In other
words, this adheres to the same rules as `natural`

above, but
using the‘`r`

’instead of‘`/`

’.
Note that this may conflict with traditional Prolog as‘`r`

’can
be defined as an infix operator. The same argument holds for `0x23`

and similar syntax for numbers that are part of the ISO standard.While the syntax is controlled by the flag rational_syntax, behavior on integer division and exponentiation is controlled by the flag prefer_rationals. See section section 4.27.2.2 for arithmetic on rational numbers.

#### 2.17.1.7 NaN and Infinity floats and their syntax

SWI-Prolog supports reading and printing‘special' floating point values according to Proposal for Prolog Standard core update wrt floating point arithmetic by Joachim Schimpf and available in ECLiPSe Prolog. In particular,

- Infinity is printed as
`1.0Inf`

or`-1.0Inf`

. Any sequence matching the regular expression`[+-]?\sd+[.]\sd+Inf`

is mapped to plus or minus infinity. `NaN`

(Not a Number) is printed as`1.xxxNaN`

, where*1.xxx*is the float after replacing the exponent by‘1'. Such numbers are read, resulting in the same`NaN`

. The`NaN`

constant can also be produced using the function nan/0, e.g.,?- A is nan. A = 1.5NaN.

By default SWI-Prolog arithmetic (see section
4.27) follows the ISO standard with describes that floating point
operations either produce a
*normal* floating point number or raise an exception.
section 4.27.2.4
describes the Prolog flags that can be used to support the IEEE special
float values. The ability to create, read and write such values
facilitates the exchange of data with languages that can represent the
full range of IEEE doubles