From 62d7b98819095db650d91f6585cbe727c9a96ab3 Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Sun, 5 Jul 2026 16:03:11 +0200 Subject: [PATCH 1/2] [tree] do not silently hide sqrt of negative value return nan instead of sqrt(abs(value)) Fixes https://github.com/root-project/root/issues/22755 Was like that since the early beginnigns https://github.com/root-project/root/blame/dd588ebc2c01182af573ea9ac7ce2ddcbc734b6e/treeplayer/src/TTreeFormula.cxx --- tree/treeplayer/src/TTreeFormula.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tree/treeplayer/src/TTreeFormula.cxx b/tree/treeplayer/src/TTreeFormula.cxx index f9c645892a408..23ed77c71b8b0 100644 --- a/tree/treeplayer/src/TTreeFormula.cxx +++ b/tree/treeplayer/src/TTreeFormula.cxx @@ -4259,7 +4259,7 @@ T TTreeFormula::EvalInstance(Int_t instance, const char *stringStackArg[]) case kfmod : pos--; tab[pos-1] = fmod_local(tab[pos-1],tab[pos]); continue; case kpow : pos--; tab[pos-1] = TMath::Power(tab[pos-1],tab[pos]); continue; case ksq : tab[pos-1] = tab[pos-1]*tab[pos-1]; continue; - case ksqrt : tab[pos-1] = TMath::Sqrt(TMath::Abs(tab[pos-1])); continue; + case ksqrt : tab[pos-1] = TMath::Sqrt(tab[pos-1]); continue; case kstrstr : pos2 -= 2; pos++;if (strstr(stringStack[pos2],stringStack[pos2+1])) tab[pos-1]=1; else tab[pos-1]=0; From 85307bdba087dddcd2970c788cc75447f60933b6 Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Sun, 5 Jul 2026 16:05:20 +0200 Subject: [PATCH 2/2] [hist] do not silently hide sqrt of nan number return nan instead of sqrt(abs(value)) for consistency with TTreeFormula --- hist/hist/src/TFormula_v5.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hist/hist/src/TFormula_v5.cxx b/hist/hist/src/TFormula_v5.cxx index 679a28a2d6ea5..0ed1fe608ad96 100644 --- a/hist/hist/src/TFormula_v5.cxx +++ b/hist/hist/src/TFormula_v5.cxx @@ -2764,7 +2764,7 @@ Double_t TFormula::EvalParOld(const Double_t *x, const Double_t *uparams) case kfmod : pos--; tab[pos-1] = fmod(tab[pos-1],tab[pos]); continue; case kpow : pos--; tab[pos-1] = TMath::Power(tab[pos-1],tab[pos]); continue; case ksq : tab[pos-1] = tab[pos-1]*tab[pos-1]; continue; - case ksqrt : tab[pos-1] = TMath::Sqrt(TMath::Abs(tab[pos-1])); continue; + case ksqrt : tab[pos-1] = TMath::Sqrt(tab[pos-1]); continue; case kstrstr : strpos -= 2; pos-=2; pos++; if (strstr(stringStack[strpos],stringStack[strpos+1])) tab[pos-1]=1;