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?
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:Qt Code:
if (qSign(myNumber) == Qt::Positive) ...To copy to clipboard, switch view to plain text mode
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.
Bookmarks