AK: Fix warnings when using FixedPoint with a precision >= 32 bits

This commit is contained in:
Tom 2022-01-20 21:29:30 -07:00 committed by Linus Groh
parent f021baf255
commit 06fc72ca0c
Notes: sideshowbarker 2024-07-18 22:57:59 +09:00

View file

@ -18,19 +18,19 @@ namespace AK {
template<size_t precision, typename Underlying>
class FixedPoint {
using This = FixedPoint<precision, Underlying>;
constexpr static Underlying radix_mask = (1 << precision) - 1;
constexpr static Underlying radix_mask = (static_cast<Underlying>(1) << precision) - 1;
public:
constexpr FixedPoint() = default;
template<Integral I>
constexpr FixedPoint(I value)
: m_value(value << precision)
: m_value(static_cast<Underlying>(value) << precision)
{
}
template<FloatingPoint F>
constexpr FixedPoint(F value)
: m_value(static_cast<Underlying>(value * (1u << precision)))
: m_value(static_cast<Underlying>(value * (static_cast<Underlying>(1) << precision)))
{
}