Maybe I should do more testing, JavaScript describes the method to find a
float as HALFEVEN. I guess this method applied when one calls the conversion
Number(), i.e. the constructor without the new keyword, which is the float/1 evaluable
function equivalent of JavaScript. The conversion Number() can be also
called for bigint arguments. So JavaScript has float/1 from a bigint like
Prolog does have. So how is this conversion described:
" In this specification, the phrase “the Number value for x” where x
represents an exact real mathematical quantity (which might even be
an irrational number such as π) means a Number value chosen in the
following manner. Consider the set of all finite values of the Number type,
with -0𝔽 removed and with two additional values added to it that are not
representable in the Number type, namely 2^1024 (which is +1 × 253 × 2971)
and -2^1024 (which is -1 × 253 × 2971). Choose the member of this set that
is closest in value to x. If two values of the set are equally close, then the
one with an even significand is chosen; for this purpose, the two extra values
2^1024 and -2^1024 are considered to have even significands. Finally, if 2^1024
was chosen, replace it with +∞𝔽; if -21024 was chosen, replace it with -∞𝔽;
if +0𝔽 was chosen, replace it with -0𝔽 if and only if x < 0; any other chosen
value is used unchanged. The result is the Number value for x. (This procedure
corresponds exactly to the behaviour of the IEEE 754-2019 roundTiesToEven mode.)"
https://tc39.es/ecma262/#sec-ecmascript-language-types-number-type
I am not sure whether I tested this already. The current test doesn’t test a tie.
Creating a tie test case is a tick more work. Also the above describes a
choice of negative zero. I should convert negative zero into positive zero
in my system, since I do not want to support that, its currently not in the
ISO core standard. But SWI-Prolog might support it:
/* SWI-Prolog 8.3.26 */
?- X is -0.0.
X = -0.0.