[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gprolog mishandles 3 mod -1
From: |
Paul Eggert |
Subject: |
gprolog mishandles 3 mod -1 |
Date: |
Fri, 05 May 2006 05:34:45 -0000 |
User-agent: |
Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux) |
gprolog 1.2.16 (and 1.2.19) mishandle the evaluation of 3 mod -1:
$ gprolog
GNU Prolog 1.2.16
By Daniel Diaz
Copyright (C) 1999-2002 Daniel Diaz
| ?- N is 3 mod -1.
N = -1
The correct answer is 0. Here's a proposed (albeit untested) patch.
2006-05-04 Paul Eggert <address@hidden>
* src/BipsPl/arith_inl_c.c (Fct_Fast_Mod): Fix bug where A mod
B was mishandled when B was negative and A was a multiple of B.
--- src/BipsPl/arith_inl_c.c~ 2002-06-24 03:26:24.000000000 -0700
+++ src/BipsPl/arith_inl_c.c 2006-05-04 22:27:10.421012000 -0700
@@ -487,7 +487,7 @@ Fct_Fast_Mod(WamWord x, WamWord y)
m = vx % vy;
- if ((m ^ vy) < 0) /* have m and vy different signs ? */
+ if (m != 0 && (m ^ vy) < 0) /* have m and vy different signs ? */
m += vy;
return Tag_INT(m);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gprolog mishandles 3 mod -1,
Paul Eggert <=