Postgresql Mathematical Operators
From w3cyberlearnings
# | Operator | Example | Result | Description |
---|---|---|---|---|
1 | addition(+) | 3+4 | 7 | addition of two or more number |
2 | subtraction(-) | 5-3 | 2 | first number minus the second number |
3 | multiplication(*) | 3*3 | 9 | times of two numbers |
4 | division(/) | 4/2 | 2 | the division of two number and integer division truncates the result |
5 | modulo(%) | 5%4 | 1 | remainder of N divided by M |
6 | exponentiation(^) | 2^3 | 8 | N power M |
7 | square root(|/) | / 25.0 | 5 | square root of N number |
8 | cube root(||/) | ||/27.0 | 3 | cube root |
9 | factorial(!) | 5! | 120 | N factorial |
10 | absolute value(@) | @ -5.0 | 5 | return absolute value |
11 | bitwise AND(&) | 91 & 15 | 11 | AND or & |
12 | bitwise OR(|) | 32 | 3 | 35 | OR or | |
13 | bitwise XOR(#) | 17#5 | 20 | XOR or # |
14 | bitwise NOT(~) | ~1 | -2 | NOT |
15 | bitwise shift left(<<) | 1<<4 | 16 | shift left |
16 | bitwise shift right(>>) | 8 >> 2 | 2 | shift right |