Well contrary to what I said just earlier, the hex one is also fairly easy. I was thinking of a similar problem, separating the thousands by a comma in a number (e.g. to obtain 56,786,564), which turns out to be a bit tricky.