remainder of dividing by zero
Jean-Michel Pichavant
jeanmichel at sequans.com
Fri Apr 13 06:05:04 EDT 2012
Ethan Furman wrote:
> Okay, so I haven't asked a stupid question in a long time and I'm
> suffering withdrawal symptoms... ;)
>
> 5 % 0 = ?
>
> It seems to me that the answer should be 5: no matter how many times
> we add 0 to itself, the remainder of the intermediate step will be 5.
>
> Is there a postulate or by definition answer as to why this should not
> be so?
>
> ~Ethan~
Considering the mathématical definition of integer division, a = bq +r,
(q, r) is unique.
With your definition, there is an infinite number of solutions fo q.
You could successfully argue that for r, only 1 solution is possible.
The french wiki page on modulo suggests some language choosed to do so
without listing those languages.
If you consider bool(5) returning True in Python, it makes no sense, but
it's really convinient and used by everyone (practicality beats purity ?)
JM
More information about the Python-list
mailing list