mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
SF patch #455966: Allow leading 0 in float/imag literals.
Consequences for Jython still unknown (but raised on Jython-Dev).
This commit is contained in:
parent
21922aa939
commit
d507dab91f
5 changed files with 84 additions and 15 deletions
|
@ -517,26 +517,26 @@ definitions:
|
|||
\production{pointfloat}
|
||||
{[\token{intpart}] \token{fraction} | \token{intpart} "."}
|
||||
\production{exponentfloat}
|
||||
{(\token{nonzerodigit} \token{digit}* | \token{pointfloat})
|
||||
{(\token{intpart} | \token{pointfloat})
|
||||
\token{exponent}}
|
||||
\production{intpart}
|
||||
{\token{nonzerodigit} \token{digit}* | "0"}
|
||||
{\token{digit}+}
|
||||
\production{fraction}
|
||||
{"." \token{digit}+}
|
||||
\production{exponent}
|
||||
{("e" | "E") ["+" | "-"] \token{digit}+}
|
||||
\end{productionlist}
|
||||
|
||||
Note that the integer part of a floating point number cannot look like
|
||||
an octal integer, though the exponent may look like an octal literal
|
||||
but will always be interpreted using radix 10. For example,
|
||||
\samp{1e010} is legal, while \samp{07.1} is a syntax error.
|
||||
Note that the integer and exponent parts of floating point numbers
|
||||
can look like octal integers, but are interpreted using radix 10. For
|
||||
example, \samp{077e010} is legal, and denotes the same number
|
||||
as \samp{77e10}.
|
||||
The allowed range of floating point literals is
|
||||
implementation-dependent.
|
||||
Some examples of floating point literals:
|
||||
|
||||
\begin{verbatim}
|
||||
3.14 10. .001 1e100 3.14e-10
|
||||
3.14 10. .001 1e100 3.14e-10 0e0
|
||||
\end{verbatim}
|
||||
|
||||
Note that numeric literals do not include a sign; a phrase like
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue