Long integer arrays in Python; how? /Carl

C

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
 
R

Robert Kern

Carl said:
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.

Use Numeric.UnsignedInt32 as the data type.

--
Robert Kern
(e-mail address removed)

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

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top