Math: Add SetBit and TestBit
This commit is contained in:
@@ -624,6 +624,13 @@ namespace Nz
|
||||
return radians * T(180.0/M_PI);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T SetBit(T number, T bit)
|
||||
{
|
||||
NazaraAssert(bit < sizeof(number)* CHAR_BIT, "bit index out of range");
|
||||
return number |= (T(1) << bit);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup math
|
||||
* \brief Converts the string to number
|
||||
@@ -689,6 +696,13 @@ namespace Nz
|
||||
return (negative) ? -static_cast<long long>(total) : total;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool TestBit(T number, T bit)
|
||||
{
|
||||
NazaraAssert(bit < sizeof(number) * CHAR_BIT, "bit index out of range");
|
||||
return number & (T(1) << bit);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup math
|
||||
* \brief Gets the degree from unit and convert it according to NAZARA_MATH_ANGLE_RADIAN
|
||||
|
||||
Reference in New Issue
Block a user