ROOT/Handling Data/ROOT Data Types

From Wikibooks, open books for an open world
Jump to navigation Jump to search

There are a couple of standard data types like int, float, double, etc. you've probably been using so far. However, despite these universally used names, there is no general agreement, what these types actually mean. In fact, it depends on your machine and compiler, how a data type will actually be stored. For example, some older standards will assign 16 bit to the int type while newer environments will use 32 bit. This might be acceptable for some applications, for data analysis it definitely isn't. As one starts to deal with huge amounts of data, one should be concerned about economic memory usage. This means to chose a data type that is big enough but nothing bigger to hold the intended value with the needed accuracy. To provide this, the programmer must be sure that the chosen data type will actually be the same on any machine the code gets compiled.

To ensure this, a number of machine independent data types that will always have the same definition has been defined in ROOT. It is strongly recommended to use this types when programming ROOT.

Type Description Size
Bool_t logical value (0…false, 1…true) ?
Char_t signed integer value 1 byte
UChar_t unsigned integer value 1 byte
Short_t signed integer value 2 bytes
UShort_t unsigned integer value 2 bytes
Int_t signed integer value 4 bytes
UInt_t unsigned integer value 4 bytes
Long_t signed integer value 8 byte
ULong_t unsigned integer value 8 byte
Float_t floating point value 4 bytes
Double_t floating point value 8 bytes

Table 1: Some of the machine independent data types defined in ROOT. See ref. [1] for all types.