?Why is 0e-6 invalid?

Steve Holden sholden at holdenweb.com
Fri Dec 22 08:31:41 EST 2000


Pearu Peterson <pearu at cens.ioc.ee> wrote in message
news:Pine.LNX.4.10.10012220922540.14068-100000 at kev.ioc.ee...
>
>
> On Thu, 21 Dec 2000, D-Man wrote:
>
> > AFIAK scientific notation is [1-9]e-?[0-9]+
> > (a 1 thru 9 followed by e followed by optional negative sign followed
> > by any sequence of 0 thru 9)
>
> Scientific notation in Python is a bit more involved:
>
> [+-]?((\d+[.]\d*|[.]\d+|[1-9]+)[eE][+-]?\d+ # may not be a complete
pattern
>
> that allows to represent number `0' also.
>
> Though, I don't understand why 0e-6 is invalid in Python, indeed.
>
> Pearu
>
>
In section 2.4.5 of the (Python 2.0) documentation it states quite clearly
that an "exponentfloat" must begin with a non-zero digit.  You will find
that

    01e-6

is also illegal syntactically.  In full: "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, "1e010" is legal, while "07.1" is a syntax error."

regards
 Steve







More information about the Python-list mailing list