4 ms·
The language in the reference manual at the end of the book (p. 188) is much more specific. It says: The binary operator / indicates division. When positive in
by fanf2 5y ago
The language in the reference manual at the end of the book (p. 188) is much more specific. It says:
The binary operator / indicates division. When positive integers are divided, truncation is toward 0, but the form of truncation is machine-dependent if either operand is negative. On all machines covered by this manual, the remainder has the same sign as the dividend. It is always true that (a/b)*b + a%b is equal to a (if b is not 0). The binary % operator yields the remainder from division of the first operand by the second.
- jounker 5y agoInteresting. If the equality must hold, then this means that a/b has different values on different architectures depending on whether a%b is positive or negative.