integer overflow

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chad Haynes

    integer overflow

    I got an odd error which I cannot explain and cannot seem to reproduce.
    The following statement

    lst[0] = num

    produced this error

    OverflowError: unsigned short is greater than maximum

    The number was around 65536 so it makes sense that it would overflow a
    short, but why is it trying to force it into a short integer?

    -Chad
  • Michael Hudson

    #2
    Re: integer overflow

    Chad Haynes <haynesc@rockef eller.edu> writes:
    [color=blue]
    > I got an odd error which I cannot explain and cannot seem to reproduce.
    > The following statement
    >
    > lst[0] = num
    >
    > produced this error
    >
    > OverflowError: unsigned short is greater than maximum
    >
    > The number was around 65536 so it makes sense that it would overflow a
    > short, but why is it trying to force it into a short integer?[/color]

    Is lst an array.array('h' ) or something (numarray...)?

    Cheers,
    mwh

    --
    An encyclopedia is about being as accurate as it can, not being
    evenly misinformed. -- Coby Beck, comp.lang.lisp

    Comment

    • Chad Haynes

      #3
      Re: integer overflow

      Michael Hudson wrote:
      [color=blue]
      > Chad Haynes <haynesc@rockef eller.edu> writes:
      >
      >[color=green]
      >>I got an odd error which I cannot explain and cannot seem to reproduce.
      >>The following statement
      >>
      >> lst[0] = num
      >>
      >>produced this error
      >>
      >> OverflowError: unsigned short is greater than maximum
      >>
      >>The number was around 65536 so it makes sense that it would overflow a
      >>short, but why is it trying to force it into a short integer?[/color]
      >
      >
      > Is lst an array.array('h' ) or something (numarray...)?[/color]

      Nope, its just a regular list
      [color=blue]
      >
      > Cheers,
      > mwh
      >[/color]

      Comment

      • Michael Hudson

        #4
        Re: integer overflow

        Chad Haynes <haynesc@rockef eller.edu> writes:
        [color=blue]
        > Michael Hudson wrote:
        >[color=green]
        > > Chad Haynes <haynesc@rockef eller.edu> writes:
        > >[color=darkred]
        > >>I got an odd error which I cannot explain and cannot seem to reproduce.
        > >>The following statement
        > >>
        > >> lst[0] = num
        > >>
        > >>produced this error
        > >>
        > >> OverflowError: unsigned short is greater than maximum
        > >>
        > >>The number was around 65536 so it makes sense that it would overflow a
        > >>short, but why is it trying to force it into a short integer?[/color]
        > > Is lst an array.array('h' ) or something (numarray...)?[/color]
        >
        > Nope, its just a regular list[/color]

        Code, please.

        Cheers,
        mwh

        --
        The snakes are optional, as are the electrodes, the molten lead
        and the ritual buggering by syphilitic warthogs.
        -- Tanuki the Raccoon-dog, asr

        Comment

        • Jp Calderone

          #5
          Re: integer overflow

          On Thu, Feb 05, 2004 at 10:58:28AM -0500, Chad Haynes wrote:[color=blue]
          > I got an odd error which I cannot explain and cannot seem to reproduce.
          > The following statement
          >
          > lst[0] = num
          >
          > produced this error
          >
          > OverflowError: unsigned short is greater than maximum
          >
          > The number was around 65536 so it makes sense that it would overflow a
          > short, but why is it trying to force it into a short integer?[/color]
          [color=blue][color=green][color=darkred]
          >>> import array
          >>> a = array.array('h' , [0])
          >>> a[0] = 10000000[/color][/color][/color]
          Traceback (most recent call last):
          File "<stdin>", line 1, in ?
          OverflowError: signed short integer is greater than maximum

          Jp


          Comment

          • Terry Reedy

            #6
            Re: integer overflow


            "Chad Haynes" <haynesc@rockef eller.edu> wrote in message
            news:_LKdnSsPRb RZ77_dRVn_vQ@ne ws.rockefeller. edu...[color=blue]
            > Michael Hudson wrote:
            >[color=green]
            > > Chad Haynes <haynesc@rockef eller.edu> writes:[color=darkred]
            > >> lst[0] = num
            > >>
            > >>produced this error
            > >>
            > >> OverflowError: unsigned short is greater than maximum
            > >>
            > >>The number was around 65536 so it makes sense that it would overflow a
            > >>short, but why is it trying to force it into a short integer?[/color]
            > >
            > >
            > > Is lst an array.array('h' ) or something (numarray...)?[/color]
            >
            > Nope, its just a regular list[/color]

            Suggestion: open interactive window, type in minimal lines of code needed
            to reproduce error, then cut and post entire window, including header that
            identifies your particular binary. Also mention the source of binary (who
            compiled, you or someone else).

            TJR





            Comment

            Working...