1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 05:17:35 +00:00

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

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) };