ValueError: invalid literal for int(): 1.0000000000e+00

Discussion in 'Python' started by =?ISO-8859-2?Q?Martin_MOKREJ=A9?=, Feb 14, 2005.

  1. Hi,
    is this a bug or "feature" that I have to use float() to make int() autoconvert
    from it?

    $ python
    Python 2.3.4 (#1, Feb 14 2005, 10:00:27)
    [GCC 3.3.5 (Gentoo Linux 3.3.5-r1, ssp-3.3.2-3, pie-8.7.7.1)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> a = 1
    >>> "%5.10e" % (a)

    '1.0000000000e+00'
    >>> int("%5.10e" % (a))

    Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    ValueError: invalid literal for int(): 1.0000000000e+00
    >>> int(float("%5.10e" % (a)))

    1
    >>>
    =?ISO-8859-2?Q?Martin_MOKREJ=A9?=, Feb 14, 2005
    #1
    1. Advertising

  2. On 2005-02-14, Martin MOKREJĀ© <> wrote:

    > is this a bug or "feature" that I have to use float() to make int() autoconvert
    > from it?


    It's a feature. Integers don't have decimal points...

    --
    Grant Edwards grante Yow! I just had a NOSE
    at JOB!!
    visi.com
    Grant Edwards, Feb 14, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tim Williams
    Replies:
    2
    Views:
    638
    Tim Williams
    May 28, 2004
  2. Terry Reedy
    Replies:
    0
    Views:
    2,784
    Terry Reedy
    Feb 15, 2005
  3. davidj411
    Replies:
    11
    Views:
    1,293
    Kam-Hung Soh
    May 29, 2008
  4. lee
    Replies:
    4
    Views:
    1,264
  5. blivori
    Replies:
    0
    Views:
    389
    blivori
    Aug 8, 2011
Loading...

Share This Page