[Numpy-discussion] int16 or int32 for C int ?
Nicolas Pernetty
nicopernetty at yahoo.fr
Mon Jun 27 00:40:12 CDT 2005
On Mon, 27 Jun 2005 09:00:52 +0200, Francesc Altet <faltet at carabos.com>
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.
>
Well It was to be interfaced with legacy code which include 'int'
declaration (which I couldn't change). So I think that I'll keep the
'sizeof' trick.
Thanks,
More information about the Numpy-discussion
mailing list