mirror of
https://github.com/SerenityOS/serenity
synced 2026-05-05 22:52:10 +02: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:
committed by
Jelle Raaijmakers
parent
605b4e96a8
commit
72ea046b68
@@ -70,7 +70,7 @@ struct AK::Formatter<Crypto::Hash::Digest<DigestS>> : StandardFormatter {
|
||||
for (size_t i = 0; i < digest.Size; ++i) {
|
||||
if (i > 0 && i % 4 == 0)
|
||||
TRY(builder.put_padding('-', 1));
|
||||
TRY(builder.put_u64(digest.data[i], 16, false, false, true, FormatBuilder::Align::Right, 2));
|
||||
TRY(builder.put_u64(digest.data[i], 16, false, false, true, false, FormatBuilder::Align::Right, 2));
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user