mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-21 09:49:21 +00:00
AK: Add Formatter<FixedPoint<...>> without floating point
Rather than casting the FixedPoint to double, format the FixedPoint directly. This avoids using floating point instruction, which in turn enables this to be used even in the kernel.
This commit is contained in:
parent
77b3230c80
commit
f021baf255
Notes:
sideshowbarker
2024-07-17 20:21:45 +09:00
Author: https://github.com/tomuta
Commit: f021baf255
Pull-request: https://github.com/SerenityOS/serenity/pull/11439
Reviewed-by: https://github.com/kleinesfilmroellchen
Reviewed-by: https://github.com/linusg ✅
4 changed files with 124 additions and 15 deletions
|
@ -315,21 +315,6 @@ private:
|
|||
Underlying m_value;
|
||||
};
|
||||
|
||||
template<size_t precision, Integral Underlying>
|
||||
struct Formatter<FixedPoint<precision, Underlying>> : StandardFormatter {
|
||||
Formatter() = default;
|
||||
explicit Formatter(StandardFormatter formatter)
|
||||
: StandardFormatter(formatter)
|
||||
{
|
||||
}
|
||||
|
||||
ErrorOr<void> format(FormatBuilder& builder, FixedPoint<precision, Underlying> value)
|
||||
{
|
||||
Formatter<double> formatter { *this };
|
||||
return formatter.format(builder, (double)value);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
using AK::FixedPoint;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue