A bug in creating array of long int.

I got the following strange value when converting a long integer into numarray. I spent some time in tracking it down in my program. Is it a bug or an expected one? Thanks.
array([True]) array([1], type=Bool) array([1]) array([1]) array([1L]) # How about preserving long int type? array([1]) array([10000000000000000L]) array([1874919424]) # Oops. The value is changed without any notice.
-- Daehyok Shin (Peter)

Daehyok Shin (Peter) wrote:
I got the following strange value when converting a long integer into numarray. I spent some time in tracking it down in my program. Is it a bug or an expected one? Thanks.
array([True]) array([1], type=Bool) array([1]) array([1]) array([1L]) # How about preserving long int type? array([1]) array([10000000000000000L]) array([1874919424]) # Oops. The value is changed without any notice.
So, what were you hoping would happen? An exception? Automatically setting type to Int64? (and if that case, what about values too large for Int64s?) (I'm assuming you are aware that Python longs are not 64 bit ints). This probably could be handled better. We'll look into it. Perry

On Sat, 2004-09-18 at 17:28, Shin wrote:
So, what were you hoping would happen? An exception? Automatically setting type to Int64?
Don't you think it is better to convert long integers into Int64, and raising at least a warning if there are values too large for Int64?
That sounds good to me. I was wondering if the array type should also be value dependent, as in driven by Python longs with values outside the range of Int32, but I think a simple rule would be best. Barring objections, I'll look into adding code that will force Int64 for any sequence containing Python longs and raise an exception for those longs which don't fit in Int64. Regards, Todd
participants (3)
-
Perry Greenfield
-
Shin
-
Todd Miller