]> Repositorios git - scryer-prolog.git/commit
Fix rnd_i clipping floats that don't fit in Fixnum
authorEmilie Burgun <[email protected]>
Fri, 17 Jan 2025 19:11:05 +0000 (20:11 +0100)
committerEmilie Burgun <[email protected]>
Sun, 26 Jan 2025 23:02:04 +0000 (00:02 +0100)
commit9420c7e41eb88e9918d82657e956088616f258d9
treef1befaf831a800fc56b863572eb03e8b51ecf3b1
parent00e6e323f861cb574dce6350390136ae99df508a
Fix rnd_i clipping floats that don't fit in Fixnum

Fixes #2772.

The current implementation of `rnd_i` incorrectly casts `f` (an `f64`)
into an `i64`, before casting it into an `Integer`.

This fixes that issue by using `Integer::try_from(f)` instead,
and failing if `f` is infinite or NaN.

A fixme is left for a future PR to properly handle the resulting errors
in floor/1 and friends (right now they can only be triggered through FFI).
src/arithmetic.rs
src/machine/arithmetic_ops.rs