diff: int.m: fix bug in `div'

Fergus Henderson fjh at cs.mu.oz.au
Tue Nov 25 06:01:11 AEDT 1997


I wrote:

> library/int.m:
>	Fix a bug in the definition of `div'.

Let me try that again :-(

Index: int.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/int.m,v
retrieving revision 1.49
diff -u -u -c -r1.49 int.m
/usr/local/bin/diff: conflicting specifications of output style
*** int.m	1997/11/24 15:27:24	1.49
--- int.m	1997/11/24 18:55:57
***************
*** 208,225 ****
  
  X div Y = Div :-
  	Trunc = X // Y,
! 	( X > 0 ->
! 		( Y > 0 ->
! 			Div = Trunc
! 		;
! 			Div = Trunc - 1
  		)
  	;
! 		( Y > 0 ->
! 			Div = Trunc - 1
! 		;
! 			Div = Trunc
! 		)
  	).
  
  X mod Y = X - (X div Y) * Y.
--- 208,222 ----
  
  X div Y = Div :-
  	Trunc = X // Y,
! 	(
! 		( X >= 0, Y >= 0
! 		; X < 0, Y < 0
! 		; X rem Y = 0
  		)
+ 	->
+ 		Div = Trunc
  	;
! 		Div = Trunc - 1
  	).
  
  X mod Y = X - (X div Y) * Y.

--
Fergus Henderson <fjh at cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3         |     -- the last words of T. S. Garp.



More information about the developers mailing list