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 Ada 1.00000E+00 / rem mod 2 1 1 -2 -1 2 -2 1 -2 2 -1 -1
2 bc / % 2 1 -2 -1 -2 1 2 -1
3 C 1.000000 / % 2 1 -2 -1 -2 1 2 -1
4 C++ 1 / % 2 1 -2 -1 -2 1 2 -1
5 GMP C mpz_div mpz_mod 2 1 -3 2 -3 2
6 Java 1 / % 2 1 -2 -1 -2 1 2 -1
7 JavaScript Node.js 1 Math.trunc(n/d) % 2 1 -2 -1 -2 1 2 -1
8 PHP 1 intdiv % 2 1 -2 -1 -2 1 2 -1
9 Python 2 1.0 / % 2 1 -3 2 -3 -2 2 -1
10 Python 3 0 // % 2 1 -3 2 -3 -2 2 -1
11 Scala 1 / % 2 1 -2 -1 -2 1 2 -1
12 Scheme Guile 0.0 quotient remainder modulo 2 1 1 -2 -1 2 -2 1 -2 2 -1 -1