managarm / frigg

Lightweight C++ utilities and algorithms for system programming
MIT License
56 stars 20 forks source link

formatting: add support for binary, octal and alternative decimal format specifiers #45

Closed ilobilo closed 1 year ago

ilobilo commented 1 year ago

This pr adds support for 'b', 'o' and 'i' format specifiers Example:

("{:b}", 28) -> 11100 // 0b11100
("{:o}", 28) -> 34 // 034
("{:i}", 28) -> 28 // 28
ArsenArsen commented 1 year ago

LGTM for the most part, but commits are written in imperative mood present tense (try adding them to the end of the sentence This commit will as a rule of thumb, i.e. this commit will add support for binary, octal ...).

out of curiosity, where did the use for {i} arise? it feels like an odd addition here (though, not necessarily a bad one).

lastly, could you add a test case for these?

ilobilo commented 1 year ago

added tests, checked that they successfully pass, changed commit and pr names and sorted 'bdioXx' in alphabetical order