2 ms·
Quantify "well known". Historically enough variation existed in this area [1], and C only happened to copy FORTRAN's behavior for the sake of compatibility. [1
by lifthrasiir 3y ago
Quantify "well known". Historically enough variation existed in this area [1], and C only happened to copy FORTRAN's behavior for the sake of compatibility.
[1] https://en.wikipedia.org/wiki/Modulo#In_programming_languages https://en.wikipedia.org/wiki/Modulo#In_programming_language...
- BlueTemplar 3y agoPython does follow the convention, but what I am wondering now is why did FORTRAN break it ?
- asplake 3y agoFortran is old – 1958 onwards. It has precedence here, though at what point it separated the two behaviours into mod and modulo functions I don’t know. Edit: From what I can tell, standardised in Fortran 90, presumably older than that.
- BlueTemplar 3y agoMy point is that Fortran doesn't have precedence on math, see this comment by Austin Feller : http://python-history.blogspot.com/2010/08/why-pythons-integer-division-floors.html?showComment=1404050838672#c3832102777815381946 http://python-history.blogspot.com/2010/08/why-pythons-integ...
- wombatpm 3y agoMaybe because FORTRAN arrays index from 1 by default?