Skip to content

%#b with field width exceeds specified width #121

@nocodo189753

Description

@nocodo189753

Hi:
my test code is :

dbg("%#10b\n", 0xf);
dbg("%#10b\n", 0xff);
dbg("%#10b\n", 0x00);
dbg("%#010b\n", 0xff);
dbg("%#010b\n", 0x00);

output ('_' means space):

_____0b1111
0b11111111
____________0
0b011111111
0000000000

It seems:

  1. if val is 0, then no "0b" prefix
  2. "%#010b\n" have an extra 0, while width should be 10 ('0b' + 8bit) if I'm right

Is these a bug or I'm using it wrong?

My env:
keil mdk 5.36.0,with segger rtt output

#define dbg_log(...) fctprintf(putchar_custom_, (void *)0, __VA_ARGS__)
#define dbg_ext(...) fctprintf(putchar_custom_, (void *)1, __VA_ARGS__)
#define dbg dbg_log

void putchar_(char ch) { SEGGER_RTT_PutChar(0, ch); }
void putchar_custom_(char ch, void *arg) { SEGGER_RTT_PutChar((int)arg, ch); }

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingresolved-on-developA changeset fixing this issue has been commiutted to the development branch

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions