]> Repositorios git - scryer-prolog.git/commitdiff
use correct signs in fixnum remainders
authorMark Thom <[email protected]>
Sat, 18 Apr 2020 23:37:54 +0000 (17:37 -0600)
committerMark Thom <[email protected]>
Sat, 18 Apr 2020 23:37:54 +0000 (17:37 -0600)
Cargo.lock
Cargo.toml
src/main.rs
src/prolog/machine/arithmetic_ops.rs

index 34a10e99ab9333ef403921e47069aeb12254c197..3fbc1d29751f36fd04f042ccb5d9e917d2b13c7a 100644 (file)
@@ -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"
index 390e1eda231219a1ae3c2ea2f09bcf057e1ac6df..25cdf90858aecbbef1b56494a3e888c2a5042089 100644 (file)
@@ -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"
index ca9ba05d857e870864669751050d56b90f182880..c8866b38e6bcb55c2a4c65be2aba2b65e2c9a1c5 100644 (file)
@@ -1,4 +1,5 @@
 extern crate crossterm;
+extern crate divrem;
 #[macro_use]
 extern crate downcast;
 extern crate git_version;
index 29137604bdbc97b5f0da795fc0dcf99a5c4de127..210748894a31e787526c778e4a4a51b983c4ae3c 100644 (file)
@@ -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)) => {