Better precision

I have a problem in calculating the integral of a histogram THD1.
My histogram is the product of two others histograms THD1. The first one was filled by reading an external file and contains data starting from 0.0325254 up to 65264.5. The second one contains, for each bean corresponding to the first one, the result of a polynomial function.
After the multiplication, I obtain data like for example 1.743870938. When I calculate the integral for this histogram, I obtain an approximated result. I investigate better and what happens is that the method GetBinContent() return for each bean an approximation of the multiplication, i.e. for the previous bean it returns 1.74387 instead of 1.743870938.
To get a better resolution as I do?

Are you sure that you get 1.74387 or is it just that you print just the six first digits? Try with cout << setprecision(9) << h->GetBinContent(1) << endl;

The multiplication is stored as a double. So the result should be equal to double(content1*content2)

You are right! It i possibile to set the precision once for all?
Thank you

setprecision does just that. At least for the stream you have manipulated. Unless you are calling any other stream manipulator afterwards, of course. Or are you looking for “fixed”?


Other than that, is is really useful to print that many digits? Is your input data really that precise, i.e. is 65264.5 really 65264.5000? Uncertainty/binning effects?