Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

According to 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.



Outlier 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_programmin...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: