converts integers to binary ternary etc and reverse