Esempio n. 1
0
        // always returns "64-bit" representation
        public List <int> GetBinary()
        {
            if (!_mainPage.isProgrammer())
            {
                return(new List <int>());
            }

            string bin = CalcHelpers.dec2Bin(Get(), (currentView as ProgrammerView).currentBits).PadLeft(MAX_BITNESS, '0');

            List <int> binArray = new List <int>();

            foreach (char c in bin.ToCharArray())
            {
                binArray.Add(int.Parse(c.ToString()));
            }

            return(binArray);
        }
Esempio n. 2
0
        private string GetExpression(string dec, bool asLong)
        {
            string exp = dec;

            if (!_mainPage.isProgrammer())
            {
                return(exp);
            }

            if (asLong)
            {
                if ((currentView as ProgrammerView).calcState == Calc_MainPage.CalcStateValues.Hex)
                {
                    exp = CalcViews.Programmer.dec2Long(dec, 16);
                }
                else if ((currentView as ProgrammerView).calcState == Calc_MainPage.CalcStateValues.Oct)
                {
                    exp = CalcViews.Programmer.dec2Long(dec, 8);
                }
                else if ((currentView as ProgrammerView).calcState == Calc_MainPage.CalcStateValues.Bin)
                {
                    exp = CalcViews.Programmer.dec2Long(dec, 2);
                }
            }

            else
            {
                if ((currentView as ProgrammerView).calcState == Calc_MainPage.CalcStateValues.Hex)
                {
                    exp = CalcHelpers.dec2Hex(dec, (currentView as ProgrammerView).currentBits);
                }
                else if ((currentView as ProgrammerView).calcState == Calc_MainPage.CalcStateValues.Oct)
                {
                    exp = CalcHelpers.dec2Oct(dec, (currentView as ProgrammerView).currentBits);
                }
                else if ((currentView as ProgrammerView).calcState == Calc_MainPage.CalcStateValues.Bin)
                {
                    exp = CalcHelpers.dec2Bin(dec, (currentView as ProgrammerView).currentBits);
                }
            }

            return(exp);
        }