1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 08:57:47 +00:00

AK: Add binary and octal mode formatting for FixedPoint

This commit is contained in:
ronak69 2023-08-14 08:58:33 +00:00 committed by Andrew Kaster
parent 352480338e
commit 2caf68fd03
3 changed files with 23 additions and 6 deletions

View file

@ -419,16 +419,21 @@ struct Formatter<FixedPoint<precision, Underlying>> : StandardFormatter {
ErrorOr<void> format(FormatBuilder& builder, FixedPoint<precision, Underlying> value)
{
u8 base;
bool upper_case;
bool upper_case = false;
if (m_mode == Mode::Default || m_mode == Mode::FixedPoint) {
base = 10;
upper_case = false;
} else if (m_mode == Mode::Hexfloat) {
base = 16;
upper_case = false;
} else if (m_mode == Mode::HexfloatUppercase) {
base = 16;
upper_case = true;
} else if (m_mode == Mode::Binary) {
base = 2;
} else if (m_mode == Mode::BinaryUppercase) {
base = 2;
upper_case = true;
} else if (m_mode == Mode::Octal) {
base = 8;
} else {
VERIFY_NOT_REACHED();
}