DataTypes

HDF and IEEEIO must be able to store any of the basic datatypes available to a given computer architecture (various sized integers and floating point numbers). In Fortran the datatype is identified by an integer. In C we use #defines. In C++ we use enums. There are also simple built-in utility operations available which allow computation of data space used by these various datatypes ( sizeOf(), nElements(), nBytes() )

Here is how the types are related.

Datatype Num Bytes C++ TypeID C TypeID Fortran TypeID
byte binary data (not to be confused with text/strings) 1 Byte,Int8 BYTE,INT8 0
short (16bit) integer 2 Int16 INT16 1
32bit integer 4 Int32 INT32 2
64bit integer 8 Int64 INT64 3
single precision floating point 4 Float32 FLOAT32 4
double precision floating point 8 Float64 FLOAT64 5
unsigned byte 1 uChar,uInt8 UCHAR,UINT8 6
unsigned short (16 bit) integer 2 uInt16 UINT16 7
unsigned 32bit integer 4 uInt32 UINT32 8
unsigned 64bit integer 8 uInt64 UINT64 9
special byte type for text data (to differentiate it from binary byte data) 1 Char,Char8,String CHAR,CHAR8,STRING 10
special type for unicode (16bit) text to differentiate from binary unsigned integer data 2 Unicode,Char16 UNICODE,CHAR16 11


Utility Subroutines

Various utility subroutines can be used to use the type information to compute data array sizes.

Number of Bytes in a Dataset

C++ Call Format
int IObase::nBytes(IObase::DataType datatype,int rank,int *dims)
C Call Format
int IOnBytes(int datatype,int rank,int *dims)
F77 Call Format
INTEGER IO_NBYTES(INTEGER datatype,INTEGER rank,INTEGER dims(*))

datatype:
The datatype for elements of the array
rank:
The number of dimensions of the array
dims:
A vector of the dimensions of the array
returns
Returns the number of bytes required to store the array

Number of Elements in a Dataset

C++ Call Format
int IObase::nElements(int rank,int *dims)
C Call Format
int IOnElements(int rank,int *dims)
F77 Call Format
INTEGER IO_NELEMENTS(INTEGER rank,INTEGER dims(*))

rank:
The number of dimensions of the array
dims:
A vector of the dimensions of the array
returns
Returns the number of elements required in the array

Size of a DataType in Bytes

C++ Call Format
int IObase::sizeOf(IObase::DataType datatype)
C Call Format
int IOsizeOf(int datatype)
F77 Call Format
INTEGER IO_SIZEOF(INTEGER datatype)

datatype:
The datatype for elements of the array.
returns
Returns the number of bytes used by an element of the specified datatype.


Last modified: Wed Feb 3 22:02:45 CST 1999