Fastest Dec to Hex and Hex to Dec conversions

Monkey Forums/Monkey Code/Fastest Dec to Hex and Hex to Dec conversions

Goodlookinguy(Posted 2014) [#1]
This is probably the fastest multiplatform solution to solving dec to hex and vice-versa. I spent quite some time on it to ensure it beat everything currently available. There is more of an explanation on this on my site. There were very good reasons things were done the way they were.

Unlike most dec to hex (and vice-versa) things, I always like to have both Big Endian and Little Endian bit order. The functions are named accordingly with the abbreviations BE and LE.

BE = Big Endian
LE = Little Endian

Dec to Hex


Hex to Dec


Example usage / testing...

Hex to Dec


Dec to Hex


Do you need proof that it's working and is faster than everyone else's solutions? Here, try for yourself. I even added the links to said functions from the other users.

CODE ~ This has the testing lines so that you can see (and test if need be) that I did not obscure the results, as I have no reason to lie about how much faster my functions are.



OUTPUT ~ This has the first 5 confirming lines that make sure each function does as it says it does. Second bit is the test from each of the functions. BE and LE ones are mine. Notice they are quite a bit faster.