Maybe you should address high bit with Integer & Long values, how to prevent overflow when converting. As is, your functions won't work with negative values