Back to index
|#define||modasgn(x, y) if (x<0) x+=y; x%=y|
|07/02/2001 09:17p 509,104 clangref.pdf from openwatcom's site Watcom C Language Reference Edition 11.0c page 118 of 297 |
|#define||modulus(x, y) ((x<0)?(x+y)%(y):(x)%(y))|
The % symbol yields the remainder from the division of the first operand by the second operand. The operands of % must have integral type.
When both operands of % are positive, the result is a positive value smaller than the second operand. When one or both operands is negative, whether the result is positive or negative is implementation-defined.