Skip to content

Commit

Permalink
Add integer binary output format (#1313)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiehuis authored and andrewrk committed Aug 1, 2018
1 parent de949b7 commit e66f538
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions std/fmt/index.zig
Expand Up @@ -248,6 +248,11 @@ pub fn formatIntValue(
return formatAsciiChar(value, context, Errors, output);
}
},
'b' => {
radix = 2;
uppercase = false;
width = 0;
},
'd' => {
radix = 10;
uppercase = false;
Expand Down Expand Up @@ -874,6 +879,10 @@ test "fmt.format" {
const value: u8 = 'a';
try testFmt("u8: a\n", "u8: {c}\n", value);
}
{
const value: u8 = 0b1100;
try testFmt("u8: 0b1100\n", "u8: 0b{b}\n", value);
}
{
const value: [3]u8 = "abc";
try testFmt("array: abc\n", "array: {}\n", value);
Expand Down

0 comments on commit e66f538

Please sign in to comment.