示例#1
0
        public void ConvertDualBCD()
        {
            StringBuilder sb = new StringBuilder();

            LongConverter conv = new LongConverter();

            for (long n = number; n != 0; n /= 10)
            {
                conv.Number = n % 10;
                conv.ConvertBinary();
                String s = conv.Result;

                // add leading zero's, if necessary
                if (s.Length == 1)
                {
                    s = "000" + s;
                }
                else if (s.Length == 2)
                {
                    s = "00" + s;
                }
                else if (s.Length == 3)
                {
                    s = "0" + s;
                }

                if (n != number)
                {
                    sb.Insert(0, " ");
                }
                sb.Insert(0, s);
            }

            this.result = sb.ToString();
        }
示例#2
0
        private static void Test02c()
        {
            LongConverter conv = new LongConverter();

            conv.Number = 123456789;
            Console.WriteLine("{0}: ", conv.Number);
            conv.GroupSize = 4;
            conv.ConvertBinary();
            Console.WriteLine(conv.Result);
        }
示例#3
0
        private static void Test02a()
        {
            LongConverter conv = new LongConverter();

            conv.Number = 987654321;
            Console.WriteLine("{0}: ", conv.Number);
            conv.GroupSize = 8;
            conv.ConvertBinary();
            Console.WriteLine(conv.Result);
        }