C Modulo Negative Number. Let us see the following programs and their outputs to get the idea. Cout << a % b / c;
Modulo and remainder operators differ with respect to negative values. Modulo operator (%) in c/c++ with examples. For one more easy trick go to next vid.
Thus, in the result (remainder), the sign of left operand is appended.
2 / 4 is 0 (using integer division) remainder 2. The purpose of this post is not explaining modular arithmetic, but if you are not familiar with it and interested in learning more, please take a look at wikipedia page as a starting point. The modulus of − 1 2 is 2. Remainder always integer number only.
Nessun commento:
Posta un commento