Re: Need help with an array problem.

2006-10-03 Thread Thomas Bellman
Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > Of course, there is also the confusion between "type cast" and "type > conversion" -- at least, for me... > cast taking the bit-pattern of a value in one "type" and > interpreting the same bit-pattern as if it were a different "type"

Re: Need help with an array problem.

2006-10-02 Thread John Machin
SpreadTooThin wrote: > Robert Kern wrote: > > [EMAIL PROTECTED] wrote: > > > To your question on casting long to short. This is how: > > > a=1234L # long > > > b=int(a) # int (short) > > > > No, a Python int is a C long. A Python long is an arbitrary-precision > > number and > > does no

Re: Need help with an array problem.

2006-10-02 Thread Robert Kern
SpreadTooThin wrote: > Robert Kern wrote: >> [EMAIL PROTECTED] wrote: >>> To your question on casting long to short. This is how: >>> a=1234L # long >>> b=int(a) # int (short) >> No, a Python int is a C long. A Python long is an arbitrary-precision number >> and >> does not correspond to

Re: Need help with an array problem.

2006-10-02 Thread SpreadTooThin
Robert Kern wrote: > [EMAIL PROTECTED] wrote: > > To your question on casting long to short. This is how: > > a=1234L # long > > b=int(a) # int (short) > > No, a Python int is a C long. A Python long is an arbitrary-precision number > and > does not correspond to any C type. > > -- So

Re: Need help with an array problem.

2006-10-02 Thread Robert Kern
[EMAIL PROTECTED] wrote: > To your question on casting long to short. This is how: > a=1234L # long > b=int(a) # int (short) No, a Python int is a C long. A Python long is an arbitrary-precision number and does not correspond to any C type. -- Robert Kern "I have come to believe tha

Re: Need help with an array problem.

2006-10-02 Thread jakobsg
To your question on casting long to short. This is how: a=1234L # long b=int(a) # int (short) John Machin skrev: > SpreadTooThin wrote: > > Basically I think the problem is in converting from a 32 bit integer to > > a 16 bit integer. > > > > I have two arrays: > > import array > > > > a

Re: Need help with an array problem.

2006-10-02 Thread John Machin
SpreadTooThin wrote: > Basically I think the problem is in converting from a 32 bit integer to > a 16 bit integer. > > I have two arrays: > import array > > a = array.array('L', [65537]) > b = array.array('H', [0]) > > b[0] = a[0] > > Which gives an overflow message As it should. > So can't

Re: Need help with an array problem.

2006-10-02 Thread James Stroud
SpreadTooThin wrote: > Basically I think the problem is in converting from a 32 bit integer to > a 16 bit integer. > > I have two arrays: > import array > > a = array.array('L', [65537]) > b = array.array('H', [0]) > > b[0] = a[0] > > Which gives an overflow message > So can't I truncate th