3 ms·
According to https://en.wikipedia.org/wiki/Modulo_operation#In_programming_languages https://en.wikipedia.org/wiki/Modulo_operation#In_programmin...: - JavaScr
by TimWolla 6y ago
According to https://en.wikipedia.org/wiki/Modulo_operation#In_programming_languages https://en.wikipedia.org/wiki/Modulo_operation#In_programmin...:
- JavaScript is consistent with Java, PHP.
- Older C may behave as either Python or JavaScript.
- Modern C behaves like JavaScript.
So basically Python is the outlier here.
- 3pt14159 6y agoOutlier is a bit of a strong word. Ruby and many others[0] implement it the same way. Personally, I think the way Ruby does it is the most intuitive. The % operator is a modulo, and there is a separate method for remainder. Even though I prefer this way, I'm dismayed that there are multiple ways of doing it. Like so many things created by humanity, we just can't ever seem to take one definition and stick to it. [0] https://en.wikipedia.org/wiki/Modulo_operation#In_programming_languages https://en.wikipedia.org/wiki/Modulo_operation#In_programmin...