What is a "float"?

According to the ISO standard, chapter 7.1.3, a "floating point" value is a "a member of a set F, which is a finite subset of R" (should really be Q) for which a floating-point representation exists (basically), with the standard using what's in ISO/IEC 13211:

https://en.wikipedia.org/wiki/ISO/IEC_10967

The is no advocation in the standard for IEEE 754 Floating-Points but practice that is what will be used as that is what a) is compatible ISO/IEC 10967 (don't know how far) and b) is what the hardware generally supports (which leads to interesting questions about NaNs, +0, -0, +oo, -oo and floating point operation error flags, how is that done in Prolog?).

See:

https://en.wikipedia.org/wiki/IEEE_754

https://en.wikipedia.org/wiki/Double-precision_floating-point_format

See this link regarding ISO Prolog conflicting with IEEE 754

http://eclipseclp.org/Specs/core_update_float.html

Assuming we are using 64-bit double precision IEEE floating points, then:

(The internal representation of a float uses base 2, so a base 10 is approximate)

Largest float:

?- X=1.7976931348623157e308, Y is X+1, Y=X.

Smallest normalized float:

X = 2.2250738585072014e-308

Smallest unnormalized float:

?- X=4.9406564584124654e-324, Y is X/2.0.

Machine epsilon (the one, which, added to 1.0, still gives a result larger than 1.0):

`efloat(C,E)`

:- `erecur(C,1.0,E)`

.

`erecur(C,X,E)`

:- Xhalf is X / 2.0, Xtest is C + Xhalf, Xtest \= C, !, `format("~e/2.0 = ~20f\n",[Xhalf,Xtest])`

, `erecur(Xhalf,E)`

.

`erecur(C,X,X)`

:- Xhalf is X / 2.0, Xtest is C + Xhalf, Xtest = C, `format("~e",[X])`

.

Then:

`efloat(1.0,X)`

.

X = 2.220446049250313e-16.

or one can directly:

?- X is epsilon.

X = 2.220446049250313e-16.

For fixed-point arithmetic, "rational numbers" (provided by the GMP library) are the correct choice: