mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:17:44 +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
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