[m-dev.] changes to integer division & remainder

Thomas Charles CONWAY conway at cs.mu.oz.au
Wed Mar 19 09:20:01 AEDT 1997


> Hi Tom,
> 
> Can you please review this diff?
> 
> (I haven't committed it yet.  There doesn't seem to be any ordering of
> commits that would allow this to bootstrap automatically, so I think
> I'll have to handle it manually.)
> 
> -----------------------------------------------------------------------------
> 
> Clean up the handlng of integer division and remainder.
> 
> library/int.m:
> 	Add a new function `div'.  The idea is that `div' is the same
> 	as `//', except that `div' will round toward minus infinity, whereas
> 	`//' will round toward zero.  `div' is more well-behaved, `//'
> 	is more efficient.
> 
> 	Change the behaviour of `mod' so that it is remainder after `div'
> 	rather than remainder after `//'.  This makes it more well-behaved,
> 	but less efficient.
> 
> 	Add a new function `rem', which is the new name for what `mod'
> 	used to do (i.e. remainder after `//').
> 
> compiler/llds.m:
> 	Add some comments about the `/' and `mod' llds operators.
> 	(The `mod' llds operator should probably be renamed `rem',
> 	but I haven't done that yet.)
> 
> compiler/code_util.m:
> 	Recognize `int:rem', rather than `int:mod', as the llds `mod'
> 	operator.
> 
> tests/hard_coded/division_test.m:
> 	Add some test cases for `div', `mod', `//', and `rem' on
> 	negative numbers.
> 

This looks fine.

-- 
Thomas Conway               				      conway at cs.mu.oz.au
AD DEUM ET VINUM	  			      Every sword has two edges.



More information about the developers mailing list