[Numpy-discussion] int16 or int32 for C int ?

Francesc Altet faltet at carabos.com
Mon Jun 27 00:02:47 EDT 2005


On Monday 27 June 2005 02:33, Nicolas Pernetty wrote:
> I would like to create a numarray array from a C buffer of 'int' but I
> don't quite know how to handle different 'int' representation (16 or 32
> bits).
>
> For instante should I use :
>
> int a[10][20];
> x = NA_NewArray(a, tInt16, 2, 10, 20);
>
> or :
> int a[10][20];
> x = NA_NewArray(a, tInt32, 2, 10, 20);
>
> Should I use some macro to determine size of int ?

As Todd said, int is 32 bits in most compilers. If you want to use
16-bit ints, use the short int declaration:

short int a[10][20];
x = NA_NewArray(a, tInt16, 2, 10, 20);

which should work on most modern platforms.

-- 
Francesc





More information about the NumPy-Discussion mailing list