PEP 238 (revised)

Manoj Plakal plakal-nospam at nospam-cs.wisc.edu
Fri Jul 27 02:48:23 EDT 2001


Guido van Rossum <guido at python.org> wrote on Thursday 26 July 2001 17:09:
> Open Issues
> 
>     - It has been proposed to call // the quotient operator.  I like
>       this.  I might rewrite the PEP to use this if enough people like
>       it.  (But isn't the assumption that this truncates towards
>       zero?)
> 

        I guess I don't really count as a show of support since
        I proposed the quotient name in an earlier post, but I
        would like to suggest using the term "quotient" throughout
        the PEP (right from the Abstract) wherever you currently
        say "floor division" or "integer division" or "truncating
        division". And maybe replace "true division" with just 
        "division" or maybe "float division" to avoid confusing people.

        Regarding the definition of quotient itself, I think
        that the mathematical definition is:
              a div b = c
              a mod b = d   [ or a divmod b = (c,d) ]
        such that
              b != 0
              0 <= d < |b|
              a = b * c + d
        
        So, -8 divmod 3 = (-3,1) and 8 divmod -3 = (-2,2) ...

        ... umm that's weird, is my definition correct?
        I'd always assumed that the mathematical definition
        only allowed non-negative remainders.

        Doesn't match Python's current divmod() built-in
        which reports divmod(8,-3) = (-3,-1)

        Also, is there a mathematical definition of quotient
        for real numbers? 'Cos the PEP wants to assign
        a meaning to // for float arguments too.

        Manoj




More information about the Python-list mailing list