# Conversion between Number Systems in Membrane Computing
## 3 Conversion between Decimal and Binary
### n-Bit m Decimal to Decimal  
To achieve the n-bit m decimal to decimal conversion (where m \(\geq\) 3), the p-system structure is designed as in Equation (8):  
\[\Pi_{\text{m\_10}}=(V,\,\mu,\,\omega_{1},\,\text{R},\,i_{\text{o}}) \tag{8}\]  
where:  
\(V=\{a,\,b,\,c,\,d,\,g,\,x,\,y,\,e,\,g,\,\lambda,f,\,r,\,p,\,q,\,u,\,z,\,v\}\)  
\(\mu=[1_{1}[2]_{2}[3]_{3}\ldots[m]_{m}]_{1}\)  
\(\omega_{1}=\{a\}\)  
\(i_{\text{o}}=1\)  
\(R_{1}=\{r_{1}\text{:}0_{a\to\text{be}},\,r_{2}\text{:}1a\to ber,\ldots,\,r_{ \text{m}}\text{:}(m-1)a\to ber^{m-1}\}\)  
\(R_{2}=\{r_{m+1}\text{:}0b\to px^{m}(n-1)c^{m}(n-1)\) (\(t,in_{2}\)) (\(\ldots\)(\(t,in_{m-1}\)), \(r_{m+2}\text{:}1b\to px^{m}(n-1)d^{m}(n-1)\) (\(t,in_{2}\)) \(\ldots\)(\(t,in_{m-1}\)), \(r_{m+3}\text{:}2b\to px^{m}(n-1)d^{m}(n-1)\) (\(px^{m}(n^{m}(n)d^{m}(n)),in_{2}\)), \(\ldots\),  
\(r_{2m}\text{:}(m-1)b\to px^{m}(n-1)c^{m}(n-1)\) (\(px^{m}(n-1)d^{m}(n-1)\),in_{2}\)) \(\ldots\)(\(px^{m}(n-1)d^{m}(n-1)\),in_{m-1}\)),  
\(r_{2m+1}\text{:}e^{\prime}\to v(u,in_{2})\ldots(u,in_{m-1})\}\)  
\(R_{3}=\{r_{2m+2}\text{:}c\to c^{2},\,r_{2m+3}\text{:}dv\to dz^{m}r^{m},\,r_{2m +4}\text{:}x\to y,\,r_{2m+5}\text{:}p\to q\}\)  
\(R_{4}=\{r_{2m+6}\text{:}z\to e,\,r_{2m+7}\text{:}cy\to\lambda,\,r_{2m+8}\text {:}dy\to\lambda,\,r_{2m+9}\text{:}q\to b\}\)  
\(R_{5}=\{r_{2m+10}\text{:}du\to d(r^{m},out),\,r_{2m+11}\text{:}x\to y,\,r_{2m +12}\text{:}p\to t\}\)  
\(R_{6}=\{r_{2m+13}\text{:}yd\to\lambda,\,r_{2m+14}\text{:}t\to\delta\}\)  
\(R_{7}=\{r_{2m+15}\text{:}u\to\lambda\}\)  
The specific P system used to convert n-bit m decimal to decimal as Figure 5.  
The task of \(\Pi_{\text{m\_10}}\) is to convert n-bit m decimal numbers to decimal numbers. Initially, 1 object \(a\) is placed in membrane 1. The rules of \(\Pi_{\text{m\_10}}\) are divided into seven subsets:  
\[\text{R}=\text{R}_{1}\cup\text{R}_{2}\cup\text{R}_{3}\cup\text{R}_{4}\cup \text{R}_{5}\cup\text{R}_{6}\cup\text{R}_{7} \tag{9}\]  
where:  
\[\text{R}_{1}=\{r_{1},\,r_{2}\ldots r_{m}\},\,R_{2}=\{r_{m+1}\ldots r_{2m+1}\},\,R_{3}=\{r_{2m+2}\ldots r_{2m+5}\},\,R_{4}=\{r_{2m+6}\ldots r_{2m+9}\}\]  
\[\text{R}_{5}=\{r_{2m+10}\ldots r_{2m+12}\},\,R_{6}=\{r_{2m+13},\,r_{2m+14}\}, \,R_{7}=\{r_{2m+15}\}\]  
\(\Pi_{\text{m\_10}}\) receives and processes the input from the environment in order from the lowest bit to the highest bit of the m-decimal number. The rules in \(\text{R}_{1}\) are used to process the lowest bit input only, and the rules in \(\text{R}_{2}\)\(\sim\)\(\text{R}_{7}\) are used to complete the processing of the other bit inputs. \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Number of** & & & & \\
**Cycles** & **Time Slice** & **Multiset of Objects** & **Implemented** & **Multiset of Objects** & **Multiset of Objects** \\
**Cycles** & **Time Slice** & **before Rule Execution** & **Rules** & **after Rule Execution** & **after Rule Execution** \\ \hline
1 & 1 & a\({}^{20}\),c & r\({}_{1}\),r\({}_{2}\) & b\({}^{2}\) g\({}^{2}\) a\({}^{4}\) d\({}^{7}\) x & \\
1 & 2 & b\({}^{2}\) a\({}^{4}\) d\({}^{7}\) g\({}^{2}\) x & r\({}_{3}\),r\({}_{4}\),r\({}_{5}\) & d\({}^{7}\) e\({}^{We assume that the binary string is \(\rm A_{n}A_{n-1}\ldots A_{1}\), and the initial decimal number \(|\,r\,|=0\). \(\rm A_{n}A_{n-1}\ldots A_{1}\) in \(\rm\Pi_{m\_10}\) is converted to a decimal number as follows:  
(1) Firstly, the system executes the first bit A1, The rules \(\rm r_{1}\) to \(\rm r_{m}\) in \(\rm R_{1}\) will be selected for execution. The current decimal number \(|\,r\,|\) is equal to the original number \(|\,r\,|\) plus the number of object \(r\) after \(\rm R_{1}\) is applied. If there are \(f\) objects \(r\) in the system, so \(|\,r\,|=|\,r\,|\,+f\). For example, If the \(\rm A_{1}\) is '\(3\)', the rule \(3a\)\(\rightarrow\)\(ber^{3}\) in \(\rm R_{1}\) is activated to consume the input value '\(3\)' and object \(a\) to generate \(1\) object \(b\) and \(e\) and \(3\) objects \(r\). Then \(|\,r\,|=|\,r\,|\,+3=3\). (2) \(\rm\Pi_{m\_10}\) executes other digits \(\rm A_{s}(1<s\leq n)\) in the order of 1, 2, 3.