News for hackers. Stuff that matters.
Re:Syntax across languages by cstuder on Monday February 02, 2015 @02:41AM (#8983123)
Something that recently caused an interesting amount of problems for me was the simple fact that the modulo operation with negative numbers changes its behaviour depending on the programming language: http://rigaux.org/language-study/syntax-across-languages/Mth...

For a more complete list: http://en.wikipedia.org/wiki/Modulo_operation#Remainder_calc...

Re:Syntax across languages by kuschku on Monday February 02, 2015 @03:48AM (#8983278)
While we had to implement the Modulo operation as part of an assignment in assembler, several other students and me started discussing this topic, ultimately settling on "do whatever you want, just write down what it’s supposed to do", because we couldn’t really agree on which would be the better solution.
Re:Syntax across languages by stouset on Monday February 02, 2015 @11:46PM (#8988894)
Actually, if you consider strict nomenclature, modulo should be positive since it's a mathematical concept and that's what it's mathematical definition would require.

The fact that it has been (ab)used as a shorthand for the remainder of integer division is unfortunate, but that suggests there ought to be a "remainder" keyword (or operator).

We've gotten into a bad habit of calling things by the name of their implementation rather than by what we actually expect of them. This confusion is just a side effect of that problem.

Re:Syntax across languages by jarcane on Monday February 02, 2015 @04:09AM (#8983338)
This is why Racket has both.
Re:Syntax across languages by aidenn0 on Monday February 02, 2015 @02:06PM (#8986061)
And Common Lisp, despite this page not having it listed.
Re:Syntax across languages by mateuszf on Monday February 02, 2015 @06:55AM (#8983753)
And Clojure too (mod and rem).