#### 2.15.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.