The requirement to move numbers between bases is something that I haven’t need to worry about in a while with most interfaces dealing strictly with a decimal base. Having said that, as the laws of the universe dictate, I have found myself of late needing to deal with hexadecimal numbers. The ability to switch between decimal and hex is something that I’ve not been able to find on the platform, although as my post on converting blobs proves I’m not always the most alert to available functionality! As such I found myself writing a little class to handle it for me.

The algorithm to move from hex to decimal and back again is well known and simple at best but still I just thought I’d chuck it out here for people to make use of and to allow me somewhere to copy and paste from if I should ever need it again. I have tried to write the class in such a way as that it could be easily extended to convert other bases; although the way it currently stands it will always need to be to and from base 10. Also, I haven’t tested using it with a base other than 16 but the theory states that it should work.

All in all it “works on my machine” or should that be “in my cloud”, actual result may vary, blah blah blah.