9.1.2 Numeric Literals数字文字

Number literals include exact-value (integer and DECIMAL) literals and approximate-value (floating-point) literals.数字文字包括精确值(整数和DECIMAL)文字和近似值(浮点)文字。

Integers are represented as a sequence of digits. 整数表示为一个数字序列。Numbers may include . as a decimal separator. 数字可能包括.作为十进制分隔符。Numbers may be preceded by - or + to indicate a negative or positive value, respectively. 数字前面可以加-+以分别表示负值或正值。Numbers represented in scientific notation with a mantissa and exponent are approximate-value numbers.在科学记数法中用尾数和指数表示的数字是近似值数字。

Exact-value numeric literals have an integer part or fractional part, or both. 精确值数字文字有整数部分或小数部分,或两者兼有。They may be signed. Examples: 1, .2, 3.4, -5, -6.78, +9.10.他们可能会加正负符号。示例:1.23.4-5-6.78+9.10

Approximate-value numeric literals are represented in scientific notation with a mantissa and exponent. 近似值数字文字用带有尾数和指数的科学符号表示。Either or both parts may be signed. 其中一方或双方均可签字。Examples: 1.2E3, 1.2E-3, -1.2E3, -1.2E-3.示例:1.2E31.2E-3-1.2E3-1.2E-3

Two numbers that look similar may be treated differently. 两个看起来相似的数字可能会被区别对待。For example, 2.34 is an exact-value (fixed-point) number, whereas 2.34E0 is an approximate-value (floating-point) number.例如,2.34是一个精确值(定点)数,而2.34E0是一个近似值(浮点)数。

The DECIMAL data type is a fixed-point type and calculations are exact. DECIMAL数据类型是定点类型,计算是精确的。In MySQL, the DECIMAL type has several synonyms: NUMERIC, DEC, FIXED. 在MySQL中,DECIMAL类型有几个同义词:NUMERICDECFIXEDThe integer types also are exact-value types. 整数类型也是精确值类型。For more information about exact-value calculations, see Section 12.25, “Precision Math”.有关精确值计算的更多信息,请参阅第12.25节,“精确数学”

The FLOAT and DOUBLE data types are floating-point types and calculations are approximate. FLOATDOUBLE数据类型是浮点类型,计算是近似的。In MySQL, types that are synonymous with FLOAT or DOUBLE are DOUBLE PRECISION and REAL.在MySQL中,与FLOATDOUBLE同义的类型是DOUBLE PRECISIONREAL

An integer may be used in floating-point context; it is interpreted as the equivalent floating-point number.整数可以在浮点上下文中使用;它被解释为等效的浮点数。