Re: Integer division, surprising results
From: Steve (dippyd_at_yahoo.com.au)
Date: 05/12/04
- Next message: Greg Ewing: "Re: Cash Register"
- Previous message: Steve: "Re: Inverse of int(s, base)?"
- In reply to: Rory Geoghegan: "Re: Integer division, surprising results"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 12 May 2004 13:52:24 +1000
Rory Geoghegan wrote:
>>I've looked at faqs and documentation, and nothing jumped out at me. Can
>>anyone explain the reasoning for this?
>
>
> According to my math book integer division is defined as such:
> a/b = q, where a = b*q + r and r is the remainder.
>
> A remainder (ei a modulo) is always positive, effectively flooring all
> the division operations.
Remainders are always positive, but modulo can be
defined as either positive or negative (for negative
arguments). There are pros and cons for doing it either
way, although the Python way seems to have more pros
than cons.
-- Steven D'Aprano
- Next message: Greg Ewing: "Re: Cash Register"
- Previous message: Steve: "Re: Inverse of int(s, base)?"
- In reply to: Rory Geoghegan: "Re: Integer division, surprising results"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
Loading