Stdlib’s Printf allows you to print
ints as unsigned octals or hexadecimals, but not as unsigned binary integers.
Does anyone have a library that can pretty print
ints as binary ints? I’m in the middle of writing one, but thought I’d ask just in case I missed something.
Ideally I’m looking for something that would output
0b1_0010 or simply
10010 when I run
Printf.printf "%a" pp_binary_int 18.
Bonus points if there’s a way to specify minimum widths:
Printf.printf "%a" (pp_binary_int ~min_width:8) 18.