Tired of printing octals and hexadecimals and then mentally converting them to bits. Ever wanted to just see the bits in an int? Now you can!
opam install pp-binary-ints and off you go:
# Pp_binary_ints.Int.to_string 0b10101001;; - : string = "10101001"
You can find the documentation for the project and more examples of how to use it here.
The library is very customizable.
- You can choose to print with
- You can choose to print zeros just like the non-zeros, with prefixes and separators.
- If you use zero padding, you can control how many leading zeros show up with the
- It correctly handles the edge cases when adding
_separators: you won’t get leading underscores.
- It includes pretty printers that work with
Fmt, not just
- Don’t like the default prefixes and suffixes? Customize the prefixes and suffixes with the provided functor.