Information lost when saving big number in tree

Hello,

I am currently trying to save big numbers out of an ASCI file in a Tree, but it turns out that the last numerics of the number have been changed due to saving in the tree.

For example the two numbers

2390265152
2390265174

out of the ASCII file should be saved in a Branch of the tree.
But if I read out the Tree both numbers are saved as:

2390265088

The numbers are stored in a Branch which is associated with a Float_t - Array. The essential storing code lines are:

TFile f(“channelTree.root”, “recreate”);
TTree *chanTree = new TTree(“channelTree”, “a simple tree”);

Float_t multy1[5];

TBranch *mult1 = chanTree->Branch(“multy1[5]”, multy1, “multy1[5]/F”);

TString StringTime;
double time;
ifstream in;
in.open(“newList.dat”);
in >> StringTime;
time = atof(StringTime)

multy1[0] = time;
mult1->Fill();

My question is, how to avoid this data lost? Thanks in advance!

With kind Regards,

Richard

Hi Richard,

‘float’ (using because of the ‘atof’) does not have enough precision. I recommend using directly a long:TFile f("channelTree.root", "recreate"); TTree *chanTree = new TTree("channelTree", "a simple tree"); ... Long_t multy1[5]; ... TBranch *mult1 = chanTree->Branch("multy1[5]", multy1, "multy1[5]/L"); ... TString StringTime; ifstream in; in.open("newList.dat"); in >> multy1[0]; ... mult1->Fill(); ...

Cheers,
Philippe

[quote=“pcanal”]Hi Richard,

‘float’ (using because of the ‘atof’) does not have enough precision. I recommend using directly a long:TFile f("channelTree.root", "recreate"); TTree *chanTree = new TTree("channelTree", "a simple tree"); ... Long_t multy1[5]; ... TBranch *mult1 = chanTree->Branch("multy1[5]", multy1, "multy1[5]/L"); ... TString StringTime; ifstream in; in.open("newList.dat"); in >> multy1[0]; ... mult1->Fill(); ...

Cheers,
Philippe[/quote]

Thank you, Phillippe! Either with Double_t or with Long_t it worked and there was no data lost any more! =D>