sharkdp/dbg-macro

Add binary printing

DerekCresswell opened this issue · 1 comments

Seeing as we can print decimal, octal, and hexadecimal it seems only right to include binary as it has it's uses as well.
I see we are using the std::setbase to convert our numbers which does not support binary (why though? Come on c++). There needs to be a bit of talk before we add this though.

Two ways to go about this :

  1. Not use std::setbase and use a more universal converter. Keeps everything more uniform but likely will be larger.
  2. Add a one off value.base == 2 inside of the pretty_print for these. Less uniform but likely easier.
  3. Add a seperate pretty_print for dbg::bin to keep everything more separate.

I've played around and made a prototype using number 2 and a decToBin function and got it printing out pretty well. I'll pretty it up and make it into a PR if we want to go this route.
It also would not be difficult to switch to a number 3 from here.

Let me know of any other ideas / options : )

I see we are using the std::setbase to convert our numbers which does not support binary (why though? Come on c++).

Exactly what I thought 🙁

I've played around and made a prototype using number 2 and a decToBin function and got it printing out pretty well. I'll pretty it up and make it into a PR if we want to go this route.

Cool! Route 2 sounds good to me.