Redundant code in Integer protocol arithmetic?

Andres Valloud sqrmax at cvtci.com.ar
Tue Dec 21 19:46:05 UTC 1999


Hi.

> In Integer protocol arithmetic (similar in '-'):
> Does anybody knows the sense of the message #normalize here? I think it
> is senseless for integer arithmetics, because #digitAdd: results in
> correct normalized numbers. The only problem could be that someone calls
> #+ with a non normalized number as argument, but I think...

I think #normalize is there because of LargeIntegers... they can get
very big with leading zeroes, so #normalize takes care of that... yet,
the lines you specifically referred to point to that if in a+b, a sign
== b sign, then it normalizes... I think it should be the other way
around. When adding, normalize becomes useless because you add bits, you
can't reduce the amount of bits of a sum by adding numbers of the same
sign. But if a sign ~= b sign, then you may end up with less bits, hence
you really need #normalize.

Perhaps it should be the other way around?

Andres.





More information about the Squeak-dev mailing list