Norbert Nemec:

And it's the processor design that makes it inefficient to correct it nowadays.

Python's definition of modulo is far more useful than C's. Implemented in machine code, however, it takes several additional commands because the integer division is hardwired to the C definition. I guess that hardware integer division in processors became popular only when C was already widely in use.

I see. Thank you for the explanations. So the situation isn't going to change soon.

Ada language offers both kind of modulus. I think std.math of Phobos should offer a mod() function that acts like the Python modulus.

Bye,
bearophile

Reply via email to