It seems like, given what mars0i@ wants, the easiest thing would be to take the output of “%h” and hack on it?
- split at the p (seems to always be present)
- use the exponent to adjust the location of the decimal (zero-padding if needed)
- convert hex-digits to four-digit binary numbers
That seems really straightforward and, it seems, reversible to produce a number in “%h” format.