I didn’t ask something about floats. I asked about arithmetic:
But I should rephrase this to arithmetic AND trigonometry functions AND
exponential functions. The scope of the flag would be not only (-)/2, (+)/3,
(*)/3, etc… but also round/2, cos/2, exp/2, etc… The ISO/IEC 13211-1 chooses
LIA for the floats of a Prolog system, and defines things like
/* 9.1.6.1 Floating point to integer rounding functions */
round(x) := floor(x + 1/2)
Float numbers and their arithmetic and their trigonometry functions and their
exponential functions occupy quite a large part of the ISO core standard for Prolog.
LIA means the above definition of round would be required if the Prolog
system uses 32-bit floats or if the Prolog system uses 64-bit floats.
The SWI-Prolog built-in evaluable function round/1 currently behaves differently.
If the representation is variable doesn’t mean the functionality is completely
variable. But the representation is indeed variable:
Edit 24.03.2022:
Similarly StrictMath and Math in Java have both 32-bit (float type in Java) and 64-bit
(double type in Java) routines. This is done via overloading. I can ask in Java:
x = Math.round(2.3f)
And then round(float)
and not round(double)
is invoked, since the literal
2.3f
is a 32-bit literal and type inference will resolved the overloading. I think
cos() has only cos(double)
and not cos(float)
variant in standard Java,
but cos(float)
is also a generally defined function in LIA as adopted by the
ISO core standard, which might have CPU, FPU, GPU, etc… support,
through instructions and/or routines.