Arithmetic Operators
Operator |
Example |
Result |
Description |
- |
-A |
Twos complement (negation) |
dash (minus sign) |
- |
A-B |
Subtraction |
dash |
+ |
A+B |
Addition |
plus sign |
Operator |
Example |
Result |
Description |
* |
A*B |
Multiplication |
asterisk |
/ |
A/B |
Unsigned integer division |
forward slash |
% |
A%B |
Modulus: remainder from / |
percent sign |
<< |
A<<B |
Shift A left by B bits |
double left angle bracket |
>> |
A>>B |
Shift A right by B bits |
double right angle bracket |
Division is unsigned integer division: the result of division is a positive integer. The remainder of a division can be obtained by using the modulus operator, "%." The shift operators perform logical unsigned shifts. Zeros are shifted in from the left during right shifts and in from the right during left shifts.