# Conversion between Number Systems in Membrane Computing
## 3 Conversion between Decimal and Binary
### Decimal to Binary
When r\({}_{7}\) is executed, it consumes objects \(y\) and \(d\) to produce object \(c\) and outputs a 1-bit binary number '0' to the environment. Rule r\({}_{8}\) executes, consuming objects \(y\) and \(f\) to produce object \(c\). Object \(c\) is generated to prepare for the next cycle. After the execution of three time slices is completed, the original \(n\) becomes \(n/2\). \(n/2\) will be used as the number of \(a\) that will execute the first time slice in the next round, that is, \(n\). The input for the next round of execution will become \(a^{n/2}c\). The system will always execute the rules in 3-time slices. In \(\Pi_{10\_2}\), \(n\) will continue to become half of the original through r\({}_{1}\), and output '0' or '1' through r\({}_{3}\) or r\({}_{7}\) until the system's rule execution conditions are not met. From the above, it can be seen that for each loop executed in \(\Pi_{10\_2}\) (which requires 3 time slices), the number of \(a\) will be reduced by half until \(\mid\!a\!\mid=0\), while generating the corresponding binary string. This indicates that \(\Pi_{10\_2}\) can correctly complete the conversion from a decimal number to a binary number. By analyzing \(\Pi_{10\_2}\), we know that each cycle will generate a 1-bit binary number and take 3-time slices. The total time slices taken by \(\Pi_{10\_2}\) are related to the converted binary digits. If the number of bits of decimal number \(n\) converted by the system is \(m\) bits, the total time spent by the system is \(3(m-1)+2\). To further illustrate the execution of \(\Pi_{10\_2}\), we list the regular execution process and the changes in the number of objects in the membrane in Table 1, using the decimal number \(n=10\) as an example. The conversion of the decimal number '10' to '1010' takes 11-time slices and 4 loops. The loop generates a binary number one bit at a time. 0, 1, 0, and 1 are generated at the 3 rd, 5 th, 9 th, and 11 th time slice, respectively. After the rules of the 11 th time slice are executed, \begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Number of** & **Time Slice** & **Multiset of** & **Implemented** & **Results** & **Output in the** \\
**Cycles** & & **Objects** & **Rules** & **Environment** \\ \hline
1 & 1 & a\({}^{10}\)\(c\) & r\({}_{1}\)\(r_{2}\) & b\({}^{5}\) g\({}^{5}\) d x & \\
1 & 2 & b\({}^{5}\) g\({}^{5}\) d x & r\({}_{4}\)\(r_{5}\) & e\({}^{5}\) g\({}^{5}\) d y & \\
1 & 3 & e\({}^{5}\) g\({}^{5}\) d y & r\({}_{6}\)\(r_{7}\) & a\({}^{5}\) c & 0 \\
2 & 4 & a\({}^{5}\) c & r\({}_{1}\)\(r_{2}\) & b\({}^{2}\) a g\({}^{2}\) d x & \\
2 & 5 & b\({}^{2}\) a g\({}^{2}\) d x & r\({}_{3}\)\(r_{4}\)\(r_{5}\) & f e\({}^{2}\) g\({}^{2}\) y & 1 \\
2 & 6 & f e\({}^{2}\) g\({}^{2}\) d x & r\({}_{6}\)\(r_{8}\) & a\({}^{2}\) c & \\
3 & 7 & a\({}^{2}\) c & r\({}_{1}\)\(r_{2}\) & b g d x & \\
3 & 8 & b g d x & r\({}_{4}\)\(r_{5}\) & e d g y & \\
3 & 9 & e d g y & r\({}_{6}\)\(r_{7}\) & a c & 0 \\
4 & 10 & a c & r\({}_{2}\) & a d x & \\
4 & 11 & a d x & r\({}_{3}\) & f x & 1 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: The process of converting a decimal number ‘10’ to a binary number ‘1010’. no more rules are satisfied in the system, the loop terminates, and the system enters the stop state.