You can use computations to convert binary numbers to decimal, and vice versa. For example, if a user enters a decimal number in an interview, you can use a computation to merge the answer in the assembled document as a binary number.
To convert binary numbers to decimal, the computation result is initialized to zero, then each digit of the binary number is analyzed inside a WHILE loop. If HotDocs finds a 1, the power of 2 corresponding to that digit is added to the result. For example, for the binary number 0101, HotDocs finds the first 1 and adds 4 to the result. When HotDocs finds the second 1, it adds only 1 to the result, for a final answer of 5.
To convert decimal numbers to binary, the computation first determines how many digits are in the binary number by comparing the original decimal number to various powers of 2. (A decimal number less than 2(21) requires only one digit; greater than 2, but less than 4 (22) requires two digits, and so on.) Once the number of digits is determined, the binary number is added to the result, one digit at a time. At the end of the computation, if the result is still empty, the computation result is "0".