Optimized binary-to-hex converter (ToHex)