User Tools

Site Tools


root:nanfinite

Treatment of non-real numbers / infinity

Idea

If the result of a calculation in your code is an infinite number or an imaginary number, this may lead to problems (when drawing histograms, etc.). The following two methods help to catch these cases.

Infinity

Include TMath.h in your header-file, and in the code write

if(!TMath::Finite(myexpression)){
...
}

to catch the cases where myexpression becomes infinite.

Imaginary number

Include TMath.h in your header-file, and in the code write

if(TMath::IsNaN(myexpression)){
...
}

to catch the cases where myexpression becomes a non-real number.

root/nanfinite.txt · Last modified: 2009/02/18 10:10 by decianm