from CWRUtil.hpp:61
class Q5
{
public:
Q5() : v(0) { }
explicit Q5(int i) : v(i) { }
Q5(const Q10 q10) : v(int(q10) / Rasterizer::POLY_BASE_SIZE) { }
operator int() const
{
return v;
}
Q5 operator-() const
{
return Q5(-v);
}
Q5 operator+(const Q5& q5) const
{
return Q5(v + q5.v);
}
Q5 operator-(const Q5& q5) const
{
return Q5(v - q5.v);
}
Q10 operator*(const Q5& q5) const
{
return Q10(v * q5.v);
}
Q5 operator*(const Q15& q15) const
{
int32_t remainder;
return Q5(muldiv(v, int(q15), Rasterizer::POLY_BASE_SIZE * Rasterizer::POLY_BASE_SIZE * Rasterizer::POLY_BASE_SIZE, remainder));
}
Q5 operator*(const int i) const
{
return Q5(v * i);
}
Q5 operator/(const int i) const
{
return Q5(v / i);
}
Q5 operator/(const Q5 q5) const
{
return Q5(int(v) * Rasterizer::POLY_BASE_SIZE / q5.v);
}
template <typename T>
T to() const
{
return v / (T)Rasterizer::POLY_BASE_SIZE;
}
private:
int32_t v;
};