mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:17:34 +00:00
AK: Add FixedPoint::clamp
This commit is contained in:
parent
7b3b743f88
commit
961e263129
1 changed files with 9 additions and 0 deletions
|
@ -95,6 +95,15 @@ public:
|
||||||
return create_raw(m_value & radix_mask);
|
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
|
constexpr This round() const
|
||||||
{
|
{
|
||||||
return This { static_cast<Underlying>(*this) };
|
return This { static_cast<Underlying>(*this) };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue