3.3. Four-Function Arithmetic
SQL is weaker than a pocket calculator. The dyadic arithmetic operators +, –, *, and / stand for addition, subtraction, multiplication, and division, respectively. The multiplication and division operators are of equal precedence and are performed before the dyadic plus and minus operators.
In algebra and in some programming languages, the precedence of arithmetic operators is more restricted. They use the “My Dear Aunt Sally” rule; that is, multiplication is done before division, which is done before addition, which is done before subtraction. This practice can lead to subtle errors.
For example, consider (largenum + largenum – largenum), where largenum is the maximum value that can be represented in its numeric ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access