Hi! I have a question :

Why sign have 2 parameters ? and how it should be used ?

(i need a function to return an int ( -1 OR 1) depending on the sign of argument ) . For an beginner mind, first thought was that this functions should be something like sign.

From what is in TMath.h the usage is :

Int_t sign = TMath::Sign( 1 , my_value ) ;

and the return will be 1 if my_value >=0 else -1

Why is not used somethig like this :

Int_t TMath::Sign( Int_t a ) { return (a>=0) ? 1 : -1 } ??

And in which cases is used the actual implementation :

Int_t TMath::Sign(Int_t a, Int_t b) { return (b >= 0) ? Abs(a) : -Abs(a); } ??

Thank you

With the two argument approach, you can have the “standard” behaviour using :

TMath::Sign(1, b)

which returns 1 or -1 depending on the sign of b,

but also you can have it return a with the same sign as b, using:

TMath::Sign(a, b)

as this might also be useful in several cases, like:

if (TMath::Sign(iy,idy) == iy)

Cheers, Fons.