I wonder if I can fill a TH1I histogram with “false double”. Indeed I had integers values, and a double function return these integers (so I ends up with number which terminate with .000000…x), so I wonder if I can still fill a TH1I with this “false double” value?
Hi,
sure you can. The “I” in “TH1I” does not mean you can only fill it with integers, it simply means maximum bin content is 2147483647, i.e. one integer per bin.
When you create a TH1I the internal vector used to store the bins is integer
When you create a TH1F the internal vector used to store the bins is float
When you create a TH1D the internal vector used to store the bins is double
In C++ when you assign a float or a double into an int then the digits after the dot are lost … obviously … it is the same here.
for the “casting” question, I wanted to understand an answer that I got some time ago by a root expert who said [1], and which really surprised me, and this is the real reason why I posted this post, because I started to thing that maybe I can’t fill a TH1I with double etc… So I wanted to clear that, and I understood now that yes, I can cast a TH1F in a TH1D, right? and if yes, why [2] does not work.