Comparison between some programming languages
about the behavior of round of 0.5
and about Euclidean division: quotient * divisor + remainder
(for example if 7/-3 = -2 and remainder = 1: 7 = -2 * -3 + 1)
  Language round(0.5) quotient remainder 7/3 remainder -7/3 remainder 7/-3 remainder -7/-3 remainder
1 C 1.000000 / % 2 1 -2 -1 -2 1 2 -1
2 C++ 1 / % 2 1 -2 -1 -2 1 2 -1
3 GMP C mpz_div mpz_mod 2 1 -3 2 -3 2
4 Java 1 / % 2 1 -2 -1 -2 1 2 -1
5 JavaScript NodeJS 1 Math.trunc(n/d) % 2 1 -2 -1 -2 1 2 -1
6 PHP 1 intdiv % 2 1 -2 -1 -2 1 2 -1
7 Python 2 1.0 / % 2 1 -3 2 -3 -2 2 -1
8 Python 3 0 // % 2 1 -3 2 -3 -2 2 -1
9 Scala 1 / % 2 1 -2 -1 -2 1 2 -1
10 Scheme Guile 0.0 quotient remainder modulo 2 1 1 -2 -1 2 -2 1 -2 2 -1 -1