I would like to format binary or hexadecimal numbers with a space separator at each 2 or 4 digit (or any other value like 8 digit or more).
A small picture is better than a long explanation, here is what I would like to do:
As you can see in this mwe, I use the fmtcount package with padzeroes:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fmtcount}
\begin{document}
Binary value : {\padzeroes[16]\binarynum{129}}$_{(2)}$ %
should display 0000 0000 1000 0001$_{(2)}$
Hexadecimal value: {\padzeroes[8]\Hexadecimalnum{65000}}$_{(16)}$ %
should display 00 00 FD E8$_{(2)}$
\end{document}
What I want to do is displaying numbers with various radix (2, 3, 7, 8, 10, 16) given a decimal number and format these numbers correctly with spaces and leading 0 (without having to perform the conversion by myself).
I already found some posts with similar questions, but none of them achieve this (they display number with thousand separators, like the numprint package, every 3 digits; or they do not make it automatic). Here are these posts :
- formating pgp - insert a space every four
- Splitting very big numbers over several lines
- Format long numbers with a thousand separator?
- How to typeset large numbers
EDIT two other linked questions:
I also prefer to use pdflatex.