Floating point literals are described by the following lexical definitions:
浮点型的字面值可以用以下词法定义描述:
floatnumber |
::= | pointfloat | exponentfloat |
pointfloat |
::= | [intpart] fraction | intpart "." |
exponentfloat |
::= | (intpart | pointfloat)
exponent |
intpart |
::= | digit+ |
fraction |
::= | "." digit+ |
exponent |
::= | ("e" | "E") ["+" | "-"] digit+ |
Note that the integer and exponent parts of floating point numbers can look like octal integers, but are interpreted using radix 10. For example, "077e010" is legal, and denotes the same number as "77e10". The allowed range of floating point literals is implementation-dependent. Some examples of floating point literals:
注意浮点数的整数部分的指数部分可以看起来像是个八进制数, 但实际上仍作为十进制处理, 例如,"077e010"是合法的, 它等价于"77e10".浮点数的允许范围是依赖于实现的,确良以是一些浮点数的例子:
3.14 10. .001 1e100 3.14e-10 0e0
Note that numeric literals do not include a sign; a phrase like
-1
is actually an expression composed of the operator
-
and the literal 1
.
注意数值型的字面值不包括符号(译注:正负号), 像-1实际上是个组合了一元运算符"-"和字面值1的表达式.