mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:27:34 +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
|
@ -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 {};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue