Log calculations in Root 5 vs Root 6

Hello,

I have a simple program to illustrate an issue I have encountered with using the natural log. While in Root 5 its value is calculated precisely, in Root 6 this is not happening. I have compared root 5 (5.27.02, old I know, but working) with root 6 (6.24.00 present version, but not working).

This is my script:

void log_changes(){
TCanvas* c1 = new TCanvas();
 
Float_t N0 = 1.5e10;
Float_t N_i = 0.;
Float_t x_i = 0.;

 TFile* BERT = TFile::Open("validation_BERT_491.root");
 TH1F* bert_15 = (TH1F*) (BERT->Get("pi_15_energy"));
 TH1F* bert_15_2 = new TH1F("bert_15_2","bert_15_2",50,0, 500);
 for (Int_t i=1; i<=50; i++)  //50 bins
   {
    N_i = bert_15->GetBinContent(i);
    x_i = log(N0/(N0-N_i));
    bert_15_2->SetBinContent(i,x_i);
   }
 bert_15_2->Draw("hist");
}

_

where log() is meant to be the natural log (ln) function. The N_i variable in here takes values in the range 200-1000, so the ratio N0/(N0-N_i) will always be very close to 1.

This small program works well ONLY in the old Root version.

Has the natural log definition changed in the recent releases?

Is Float_t not the ideal choice for Root 6 to calculate these correctly?

Thank you for any help you could offer,

Best regards,

Cristian
__
Please read tips for efficient and successful posting and posting code

_ROOT Version: 6.24.00
_Platform: MacOSX Big Sur
Compiler: Not Provided


Use “Double_t” instead of “Float_t”.

Thank you