AK: Add FixedPoint::clamp

This commit is contained in:
kleines Filmröllchen 2023-02-09 15:35:29 +01:00 committed by Andrew Kaster
parent 7b3b743f88
commit 961e263129
Notes: sideshowbarker 2024-07-16 23:44:31 +09:00

View file

@ -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<Underlying>(*this) };