8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

正文为中文,英文原文默认隐藏。点击任意中文段落即可展开 / 收起对应英文原文。

打开官方英文原文 ↗

译文由机器翻译生成,仅供理解参考;有疑问请以官方英文原文为准。

中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 100%

11.1.2 数字字面量11.1.2 Numeric Literals

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

整数表示为一系列数字。数字可以使用 . 作为小数分隔符。数字前可以加 - 或 + 以表示负值或正值。用尾数和索引表示的科学记数法数字是近似值数。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.

精确值数字字面量具有整数部分或小数部分,或者两者都有。它们可以带符号。示例:1、.2、3.4、-5、-6.78、+9.10。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.2E3、1.2E-3、-1.2E3、-1.2E-3。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.

两个看起来相似的数字可能会被不同处理。例如,2.34是精确值(定点)数字,而2.34E0是近似值(浮点)数字。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.

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

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

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