[Numpy-discussion] What type should / return in python 3kwhenapplied to two integer types?

Nadav Horesh nadavh@visionsense....
Thu Aug 27 14:13:34 CDT 2009

How about making this arch dependent translation:

short int -> float
int -> double
long int -> long double

or adding a flag that would switch between the above translation to the option that would produce only doubles.

For some computing projects I made I would prefer the first option: There I used huge array, and could not afford having extra precision of the account of memory consumption.  Currently I do a  lot of (8 and 16 bits) image processing, memory size is not a problem, and it feels nice not to worry about precision (think about the bad habits of Matlab users).


-----הודעה מקורית-----
מאת: numpy-discussion-bounces@scipy.org בשם Charles R Harris
נשלח: ה 27-אוגוסט-09 21:54
אל: Discussion of Numerical Python
נושא: Re: [Numpy-discussion] What type should / return in python 3kwhenapplied to two integer types?
On Thu, Aug 27, 2009 at 12:50 PM, Charles R Harris <
charlesr.harris@gmail.com> wrote:

> 2009/8/27 Nadav Horesh <nadavh@visionsense.com>
>> Double is the natural choice, there is a possibility of long double
>> (float96 on x86 or float128 on amd64) where there is no precision loss. Is
>> this option portable?
> Not really. The long double type can be a bit weird and varies from
> architecture to architecture.

The real problem is deciding what to do with integer precisions that fit in
float32.  At present we have

In [2]: x = ones(1, dtype=int16)

In [3]: true_divide(x,x)
Out[3]: array([ 1.], dtype=float32)


More information about the NumPy-Discussion mailing list