Skip to content

Overview of Arithmetic Operators

Name Description
%,MOD Take the rest
* Multiplication
+ Addition
- Subtraction
- minus sign
/ Division
DIV Integer Divide

— For -, + and *, if both operand values ​​are integers, the calculation results will be calculated with BIGINT (64-bit) accuracy.

— If both operand values ​​are integers and either of them are unsigned, the result is an unsigned integer.

— If any of the operation values ​​in +, -, /, *, % is a real value or string value, the accuracy of the result is the maximum precision of the operation.

When using / for division, when using two exact value operations, the accuracy range of the result is the accuracy range of the first operation value plus the value of the div_precision_increment system variable. For example, the result of the expression 5.05 / 0.014 has a decimal 8 bit precision (360.71428571).

These rules apply to each operation, such as nesting calculations to take the accuracy of each component. Therefore, (14620 / 9432456)/(24250 / 9432456) is first parsed to (0.0014)/(0.0026), and the final result has 16 decimal places (0.6028865979381443).

limit

  • The arithmetic operator is only suitable for calculations between numbers.
  • Ensure the accuracy criteria for the calculation of each component and child components, see [Overview of cast functions and operators] (../cast-functions-and-operators/cast-functions-and-operators-overview.md).