Long integer arrays in Python; how? /Carl

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

    #1

    Long integer arrays in Python; how? /Carl

    I have the following problem

    import Numeric
    dim = 1
    bits = 32
    v = Numeric.zeros(( dim, bits), 'l')
    for j in range(bits):
    v[0][j] = 1L << bits - j - 1

    The problem is the last assignment, which is not valid, since the integer is
    on the right hand side is to large to be assigned to an array element.

    Is there a way around this problem in Python?

    Yours /Carl
  • Robert Kern

    #2
    Re: Long integer arrays in Python; how? /Carl

    Carl wrote:[color=blue]
    > I have the following problem
    >
    > import Numeric
    > dim = 1
    > bits = 32
    > v = Numeric.zeros(( dim, bits), 'l')
    > for j in range(bits):
    > v[0][j] = 1L << bits - j - 1
    >
    > The problem is the last assignment, which is not valid, since the integer is
    > on the right hand side is to large to be assigned to an array element.[/color]

    Use Numeric.Unsigne dInt32 as the data type.

    --
    Robert Kern
    robert.kern@gma il.com

    "In the fields of hell where the grass grows high
    Are the graves of dreams allowed to die."
    -- Richard Harter

    Comment

    Working...