While a number of commonly needed basic math functions can be used, such as qSin() or qSqrt(), how come Qt is not offering a qSgn() function to determin the sign of a real?
Printable View
While a number of commonly needed basic math functions can be used, such as qSin() or qSqrt(), how come Qt is not offering a qSgn() function to determin the sign of a real?
Thinking about how to implement such function; would it make life easier?
It should return something like Qt::Negative or Qt::Positive or Qt::Zero so you can write:
instead of:Code:
if (qSign(myNumber) == Qt::Positive) ...
Code:
if (myNumber > 0.0) ...
I don't think I would use qSign()... ;)
Actually the (mathematical) definition of Sgn(x) function is 1 if x > 0, 0 if x=0 and -1 if x < 0. And indeed there are some uses for it.