Ejemplo n.º 1
0
        public static string DecimalToOctal(string input)
        {
            int        intInput;
            List <int> repository = new List <int>();
            bool       check      = Int32.TryParse(input, out intInput);

            while (intInput > 8 & check)
            {
                var a = intInput % 8;
                repository.Add(a);
                if (a == 0)
                {
                    intInput /= 8;
                }
                else
                {
                    while (intInput % 8 != 0)
                    {
                        intInput--;
                    }
                    intInput /= 8;
                }
            }
            repository.Add(intInput % 8);
            repository.Reverse();
            return(Instruments.ListToString(repository));
        }
Ejemplo n.º 2
0
        // int values - division method
        public static string DecimalToBinary(string input)
        {
            int        intInput;
            List <int> binaryRepository = new List <int>();
            bool       check            = Int32.TryParse(input, out intInput);

            // if temp = 1 then it is the end of dividing
            while (intInput != 1 & check)
            {
                var a = intInput % 2;
                binaryRepository.Add(a);
                if (a == 1)
                {
                    intInput--;
                    intInput /= 2;
                }
                else
                {
                    intInput /= 2;
                }
            }
            binaryRepository.Add(1);
            binaryRepository.Reverse();
            return(Instruments.ListToString(binaryRepository));
        }
Ejemplo n.º 3
0
        public static string DecimalToOctal(string input)
        {
            DigitRemainderCount(input);
            List <int> repository = new List <int>();
            double     temp       = Convert.ToDouble(input);

            while (repository.Count <= digit)
            {
                var check = temp * 8;
                repository.Add((int)check);
                if (check > 1)
                {
                    while (check > 1)
                    {
                        check--;
                    }
                    temp = check;
                }
                else
                {
                    temp = check;
                }
            }
            return("0." + Instruments.ListToString(repository));
        }