diff --git a/AK/FixedPoint.h b/AK/FixedPoint.h index d4513efa19..9b4c717ec0 100644 --- a/AK/FixedPoint.h +++ b/AK/FixedPoint.h @@ -95,6 +95,15 @@ public: return create_raw(m_value & radix_mask); } + constexpr This clamp(This minimum, This maximum) const + { + if (*this < minimum) + return minimum; + if (*this > maximum) + return maximum; + return *this; + } + constexpr This round() const { return This { static_cast(*this) };