binary, ternary, and hex conversion functions