binary and trinary converter