[m-rev.] for review: implement checked division for uints
novalazy at gmail.com
Thu May 11 12:41:40 AEST 2017
On Wed, 10 May 2017 13:10:07 +1000 (AEST), Julien Fischer <jfischer at opturion.com> wrote:
> For review by anyone.
> The int module also provides div/2 and mod/2 which round differently for
> negative results than / and rem. The result cannot (obviously) be
> negative for uints; do we want to provide div/2 and mod/2 as synonyms for
> / and rem in the uint module? (mod in particular is the obvious name
> for the operation.)
I think so, especially mod.
> Note: I will update the expected output for 32-bit system before I
> Implement checked division for uints.
> Add (//)/2, (/)/2 and rem/2 for uints.
> Enable the division tests.
> Update the expected output.
> diff --git a/library/uint.m b/library/uint.m
> index f757cd78e..a0088ab36 100644
> --- a/library/uint.m
> +++ b/library/uint.m
> @@ -77,8 +77,31 @@
> :- func min(uint, uint) = uint.
> + % Integer division.
> + %
> + % Throws a `math.domain_error' exception if the right operand is zero.
> + %
> +:- func (uint::in) // (uint::in) = (uint::uo) is det.
int.m specifies "Truncating" integer division
The rest looks fine.
More information about the reviews