Double32_t tradeoffs


We are strongly considering moving to use Double32_t rather than Double_t in some pre-existing ROOT classes. What compromises were required to get a double stored in the ROOT files in the size of a float?
Are there any details of the algorithm used to pack those variables when written to file?


Hi Heather,

In memory a Double32_t is like a Double_t.
When writing a Double32_t to a file, it is converted to a 32 bit Float_t,
ie instead of 14 significative digits, you will get only 7.
When reading back the 32 bit Float_t is converted to a Double_t.

Note that, thanks to the automatic schema evolution mechanism,
you can change an existing type from Double_t to Double32-t
or vice-versa.


Hi Rene,

So we literally only have 7 significant digits - so there’s no magic in terms of saving something closer to the precision of a Double_t when using Double32_t. So I can only imagine is that this type is meant more for those who want to work with Doubles during analysis and don’t mind that their data has the precision of a Float_t.

Just making sure I get it …and then we can figure out where we want to use Double32_t

Take care,

Hi Heather,

Yes you got it. Double32_t is interesting if your data does not have
more than 7 significative digits and you still want to use it as a Double_t
when making arithmetic operations.

We are currently discussing another type (say DoubleI_t) that will
save a Double_t with at least 9 significative digits. To make this possible,
you will have to specify a range for the data member, eg
DoubleI_t fAngle; //[-pi,pi]

The syntax above is just to give an indication, we are currently discussing it. This new type will probably be included in 4.04 at the end of April.


Hi Heather,

We have made progress on this issue. Instead of adding a new data type
we have extended the possibilities of Double32_t.
For more details, see … teDouble32

This doc includes a picture showing the performance of the Double32_t.
This picture is produced by the new tutorial (in CVS) double32.C