[Cuis-dev] Problems in class Number

Andres Valloud ten at smallinteger.com
Tue Oct 8 10:25:02 PDT 2019


Hello,

On 10/8/19 04:11, Juan Vuletich wrote:
>> Assuming the code is broken and needs to be fixed, alternatively one 
>> could also write the initial guard clause like this:
>>
>>     n = 0 ifTrue: [^1 \\ m].
>>
>> because the case m = 0 will fail.
>> ...
> 
> Just added this suggestion as an update to GitHub. Andrés, I did it with 
> your author initials, it's your code!

Ok :).  The same needs to happen in raisedToInteger:modulo:.

	(exp = 0) ifTrue: [^ 1 \\ m].

It's interesting that with this approach, both

	3 raisedTo: 0 modulo: 0

and

	3 raisedTo: 0 modulo: 1

answer zero, like they should (in the last case, because 1 modulo 1 is 
zero).  Hopefully I'm not missing anything here.

Andres.


More information about the Cuis-dev mailing list