tencent cloud

All product documents
TDSQL-C for MySQL
Description of Supported Arithmetic
Last updated: 2025-03-07 11:41:50
Description of Supported Arithmetic
Last updated: 2025-03-07 11:41:50
Currently, the read-only analysis engine supports most of MySQL's arithmetic logic, but there are still restrictions and incompatibilities in certain scenarios. This document introduces supported arithmetic in the read-only analysis engine, and enumerates type restrictions on input parameters. Input parameters and usage methods not mentioned in the document are not supported.

Arithmetic Usage Restrictions

Division operations of decimal type: The decimal places of the result will be truncated based on the number of the dividend's decimal places + 4. For example, for Decimal(9, 1) / Decimal(9, 1), the decimal places are truncated based on 5.
Addition, subtraction, multiplication, and division operations of decimal type: If the total length of the result exceeds 65, an "out of range" error message will be displayed. The maximum decimal data type length supported in the read-only analysis engine is 65.
Mathematical operations between any numeric type and floating-point type (float or double): There is always a precision error. The core cause is that floating-point types such as double are not field types with strict precision. Even in MySQL practice, it is not recommended to perform mathematical calculations between numeric types and floating-point types.
Arithmetic of non-numeric types: It involves implicit conversion. Due to the limitation of CAST function support in the read-only analysis engine, related arithmetic will not be supported in certain scenarios if CAST is not supported. For detailed information on CAST support, see Description of Type Conversion Function Support.

Supported Arithmetic Types

Addition Operator (+)

Syntax: op1 + op2 Supported value types for op1: int, bigint, float, double, and decimal. Supported value types for op2: int, bigint, float, double, and decimal.

Subtraction Operator (-)

Syntax: op1 - op2 Supported value types for op1: int, bigint, float, double, and decimal. Supported value types for op2: int, bigint, float, double, and decimal.

Multiplication Operator (*)

Syntax: op1 op2 Supported value types for op1: int, bigint, float, double, and decimal. Supported value types for op2: int, bigint, float, double, and decimal.

Division Operator (/)

Syntax: op1 / op2 Supported value types for op1: int, bigint, float, double, and decimal. Supported value types for op2: int, bigint, float, double, and decimal.

Modulo Operator (%)

Syntax: op1 % op2 Supported value types for op1: int, bigint, float, double, and decimal. Supported value types for op2: int, bigint, float, double, and decimal.
Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

7x24 Phone Support
Hong Kong, China
+852 800 906 020 (Toll Free)
United States
+1 844 606 0804 (Toll Free)
United Kingdom
+44 808 196 4551 (Toll Free)
Canada
+1 888 605 7930 (Toll Free)
Australia
+61 1300 986 386 (Toll Free)
EdgeOne hotline
+852 300 80699
More local hotlines coming soon