Is anybody coming from Pascal?

Steve Horne sh at ttsoftware.co.uk
Mon Jul 23 11:34:01 EDT 2001


On Mon, 23 Jul 2001 12:12:24 +0200 (MET DST), Mikael Olofsson
<mikael at isy.liu.se> wrote:

>
>On 21-Jul-2001 Stephen Horne wrote:

> >  I just think integer division should round towards zero - not strictly
> >  downwards.
>
>In my research I toss a lot of finite fields around. These are mathematical
>entities where modulo reduction is used all the time. The mathematical 
>concept of modulo is one of equivalence. If a, b, and c, are integers, you 
>say that a and b are equal (or equivalent) modulo c if there is an integer 
>d such that 
>
>  a == b + c*d 
>
>holds. For instance

I'm aware - it gets common applications in crytography. Properties I
like, for instance, include that with a prime modulo, division is a
strict one-to-one mapping except when the divisor is zero - it works
as a strict inverse to multiplication, but it isn't always to easy to
figure out the result ;-)

Personally, I think this would work best with an equivalent of a
template class - the modulo becomes part of the numeric type, and
trying to mix modulo types becomes an error.

I understand your view, but I don't think it should apply to integers
in general - but it does, and that's no big deal either. And I agree
that it's arguably more consistent to always round lower (or at least
in a consistent direction, as you say), and therefore it no doubt
saves unnecessary checks in many cases. 

Trouble is, the way things are going, the fact that I have a valid
opinion (irrespective of the alternative and arguably better opinions)
might just be enough to get Python changed. After all, its different
and it'll break existing code so why not? Maybe I should have kept
quiet ;-)

-- 
Steve Horne
Home : steve at lurking.demon.co.uk
Work : sh at ttsoftware.co.uk



More information about the Python-list mailing list