Mathematical Operators
This section covers mathematical operators. Subsequent sections cover specific mathematical functions.
Operator | Function | Example | Result |
---|---|---|---|
+ | Addition | 99+2 | 101 |
- | Subtraction | 99-2 | 97 |
* | Multiplication | 99*2 | 198 |
/ | Division | 99/2.0 | 49.5 |
% | Modulo | 99 % 2 | 1 |
^ | Exponentiation | 99 ^ 2 | 9801 |
|/ | Square root. See SQRT | |/ 99 | 9.94 |
||/ | Cube root. See CBRT | ||/ 99 | 4.62 |
& | Bitwise AND | 25 & 20 | 16 |
| | Bitwise OR | 25 | 20 | 29 |
# | Bitwise XOR | 25 # 20 | 13 |
~ | Bitwise NOT | ~ 25 | -26 |
<< | Bitwise shift left | 25 << 20 | 26214400 |
>> | Bitwise shift right | 25 >> 20 | 0 |
Note that the division of integers produces different results from the division of decimal values.
The bitwise operators work only with SMALLINT, INTEGER, and BIGINT data types. The other operators work with all numeric data types.
Parent topic:Mathematical Functions