Does `mod` depend on `div`?

I'm guessing that's what's going on. From Wikipedia's "Modulo operation" entry:

"Although typically performed with a and n both being integers, many
computing systems now allow other types of numeric operands."

https://en.wikipedia.org/wiki/Modulo_operation

Best, Bill.


On Sat, Dec 18, 2021 at 7:25 AM Sean McAfee <eef...@gmail.com> wrote:
>
> While coding today, I was a little surprised to discover that the div 
> operator doesn't coerce its arguments to integers.  So for example, the 
> expressions 25 div '5' and pi div 5 raise errors.  I checked the Operators 
> doc page and saw that, sure enough, div (and mod, I found) accept only actual 
> Ints.  Of all numeric operators at the multiplicative and additive levels of 
> precedence, they're alone in that respect.
>
> Is there a particular reason these two operators are so restrictive?

Reply via email to