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

Nicolas Pernetty nicopernetty at yahoo.fr
Mon Jun 27 00:36:48 EDT 2005


On Sun, 26 Jun 2005 21:28:25 -0400, Todd Miller <jmiller at stsci.edu>
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).
> 
> On the platforms we test on at least,  int == Int32.  This is even
> true for the 64-bit platforms I've seen.
> 
> > 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 ?
> 
> You can do that with: sizeof(int)
> 

Ok so If I want to make a really multiplatforms program, I should type :

int a[10][20];
if (sizeof(**a)==4)
    x = NA_NewArray(a, tInt32, 2, 10, 20);
else
    x = NA_NewArray(a, tInt16, 2, 10, 20);

This is the recommended way ?

Thanks !




More information about the NumPy-Discussion mailing list