如何把二進位制轉化為十二進位制
string sbinary = "0111111111"; int iv = Convert.ToInt32(sbinary, 2); Console.WriteLine(iv); System.Collections.ArrayList al=new System.Collections.ArrayList();int t=0;do { al.Add(Convert.ToString(iv%12) );t++;iv=iv/12;} while(iv!=0);//改為a!=0 System.Collections.ArrayList al1=new System.Collections.ArrayList();for(int i=t-1;i>=0;i--)//此處為i=t-1; { if(al[i].ToString()=="10") al1.Add("A"); else if(al[i].ToString()=="11") al1.Add("B"); else al1.Add(al[i].ToString() );} string Result="";for(int j=0;j<al1.Count;j++)Result+=al1[j].ToString();Console.WriteLine(Result);
如何把二進位制轉化為十二進位制
string sbinary = "0111111111"; int iv = Convert.ToInt32(sbinary, 2); Console.WriteLine(iv); System.Collections.ArrayList al=new System.Collections.ArrayList();int t=0;do { al.Add(Convert.ToString(iv%12) );t++;iv=iv/12;} while(iv!=0);//改為a!=0 System.Collections.ArrayList al1=new System.Collections.ArrayList();for(int i=t-1;i>=0;i--)//此處為i=t-1; { if(al[i].ToString()=="10") al1.Add("A"); else if(al[i].ToString()=="11") al1.Add("B"); else al1.Add(al[i].ToString() );} string Result="";for(int j=0;j<al1.Count;j++)Result+=al1[j].ToString();Console.WriteLine(Result);