[m-rev.] for review: implement checked division for uints
Julien Fischer
jfischer at opturion.com
Fri May 12 23:14:20 AEST 2017
Hi Peter,
On Thu, 11 May 2017, Peter Wang wrote:
> 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.
Done.
>> Note: I will update the expected output for 32-bit system before I
>> commit.
>>
>> -----------------------------
>>
>> Implement checked division for uints.
>>
>> library/uint.m:
>> Add (//)/2, (/)/2 and rem/2 for uints.
>>
>> tests/hard_coded/uint_arith.m
>> Enable the division tests.
>>
>> tests/hard_coded/uint_bitwise.exp:
>> Update the expected output.
>>
>> Julien.
>>
>> 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
I've added that here too.
Julien.
More information about the reviews
mailing list