mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 20:17:44 +00:00
AK: Add option to the string formatter to use a digit separator
`vformat()` can now accept format specifiers of the form {:'[numeric-type]}. This will output a number with a comma separator every 3 digits. For example: `dbgln("{:'d}", 9999999);` will output 9,999,999. Binary, octal and hexadecimal numbers can also use this feature, for example: `dbgln("{:'x}", 0xffffffff);` will output ff,fff,fff.
This commit is contained in:
parent
605b4e96a8
commit
72ea046b68
5 changed files with 54 additions and 20 deletions
|
@ -443,7 +443,7 @@ struct Formatter<FixedPoint<precision, Underlying>> : StandardFormatter {
|
|||
i64 integer = value.ltrunk();
|
||||
constexpr u64 one = static_cast<Underlying>(1) << precision;
|
||||
u64 fraction_raw = value.raw() & (one - 1);
|
||||
return builder.put_fixed_point(is_negative, integer, fraction_raw, one, base, upper_case, m_zero_pad, m_align, m_width.value(), m_precision.value(), m_fill, m_sign_mode, real_number_display_mode);
|
||||
return builder.put_fixed_point(is_negative, integer, fraction_raw, one, base, upper_case, m_zero_pad, m_use_separator, m_align, m_width.value(), m_precision.value(), m_fill, m_sign_mode, real_number_display_mode);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue