From: Mark Thom Date: Sat, 18 Apr 2020 23:37:54 +0000 (-0600) Subject: use correct signs in fixnum remainders X-Git-Tag: v0.8.123~130 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=2c8858ff2dd14582b248a12f71ca0564a9966005;p=scryer-prolog.git use correct signs in fixnum remainders --- diff --git a/Cargo.lock b/Cargo.lock index 34a10e99..3fbc1d29 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -146,6 +146,11 @@ dependencies = [ "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "divrem" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "downcast" version = "0.10.0" @@ -614,6 +619,7 @@ version = "0.8.120" dependencies = [ "crossterm 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", "dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "divrem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "downcast 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "git-version 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -814,6 +820,7 @@ dependencies = [ "checksum crossterm_winapi 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "057b7146d02fb50175fd7dbe5158f6097f33d02831f43b4ee8ae4ddf67b68f5c" "checksum dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "13aea89a5c93364a98e9b37b2fa237effbb694d5cfe01c5b70941f7eb087d5e3" "checksum dirs-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "afa0b23de8fd801745c471deffa6e12d248f962c9fd4b4c33787b055599bde7b" +"checksum divrem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc9f8914dcb99891bdfee82536bbff8d9aa612b0dbe83872afbc66902bdec0b9" "checksum downcast 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4bb454f0228b18c7f4c3b0ebbee346ed9c52e7443b0999cd543ff3571205701d" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" diff --git a/Cargo.toml b/Cargo.toml index 390e1eda..25cdf908 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,13 +18,14 @@ num = ["num-rug-adapter", "prolog_parser/num"] [dependencies] crossterm = "0.16.0" dirs = "2.0.2" +divrem = "0.1.0" downcast = "0.10.0" git-version = "0.3.4" indexmap = "1.0.2" lazy_static = "1.4.0" libc = "0.2.62" nix = "0.15.0" -num-rug-adapter = { optional = true, version = "0.1.1" } +num-rug-adapter = { optional = true, version = "0.1.2" } ordered-float = "0.5.0" prolog_parser = { version = "0.8.52", default-features = false } ref_thread_local = "0.0.0" diff --git a/src/main.rs b/src/main.rs index ca9ba05d..c8866b38 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ extern crate crossterm; +extern crate divrem; #[macro_use] extern crate downcast; extern crate git_version; diff --git a/src/prolog/machine/arithmetic_ops.rs b/src/prolog/machine/arithmetic_ops.rs index 29137604..21074889 100644 --- a/src/prolog/machine/arithmetic_ops.rs +++ b/src/prolog/machine/arithmetic_ops.rs @@ -1,3 +1,5 @@ +use crate::divrem::*; + use crate::prolog_parser::ast::*; use crate::prolog::arithmetic::*; @@ -990,7 +992,7 @@ impl MachineState { stub, )) } else { - Ok(Number::from(n1 % n2)) + Ok(Number::from(n1.rem_floor(n2))) } } (Number::Fixnum(n1), Number::Integer(n2)) => {