Exemplo n.º 1
0
    public void Mul(long pMulNum)
    {
        bool isPositive = (pMulNum >= 0);

        isPositiveNumber = (isPositiveNumber == isPositive);

        ulong mulNum = (ulong)(pMulNum * (isPositive ? 1 : -1));

        Unit.DivisionUnit divition = new Unit.DivisionUnit();

        divition.SetDivisionUnit((ulong)byte.MaxValue, 10);
        ulong max = divition.Quotien;

        List <byte> lstMulNum = new List <byte>(2);

        while (mulNum != 0)
        {
            divition.SetDivisionUnit(mulNum, max);

            lstMulNum.Add((byte)divition.Remainder);
            mulNum = divition.Quotien;
        }

        List <byte> copyList = Copy();

        Set(0);

        List <byte> mulList = new List <byte>(2);

        for (int i = 0; i < lstMulNum.Count; ++i)
        {
            mulList.Clear();
            for (int j = 0; j < copyList.Count; ++j)
            {
                byte mulValue = (byte)(copyList[j] * lstMulNum[i]);
                mulList.Add(mulValue);
            }
            CheckOver(mulList);

            for (int z = 0; z < i; ++z)
            {
                for (int j = 0; j < copyList.Count; ++j)
                {
                    byte mulValue = (byte)(mulList[j] * max);
                    mulList[j] = mulValue;
                }
                CheckOver(mulList);
            }

            Add(mulList);
            CheckOver(powList);
        }
    }
Exemplo n.º 2
0
    public void Set(long pSetNum)
    {
        powList.Clear();

        isPositiveNumber = (pSetNum >= 0);

        ulong setNum = (ulong)(pSetNum * (isPositiveNumber ? 1 : -1));

        Unit.DivisionUnit divition = new Unit.DivisionUnit();

        while (setNum != 0)
        {
            divition.SetDivisionUnit(setNum, 10);

            powList.Add((byte)divition.Remainder);
            setNum = divition.Quotien;
        }

        CheckOver(powList);
    }
Exemplo n.º 3
0
    public void Add(long pAddNum)
    {
        bool isPositive     = (pAddNum >= 0);
        bool isSamePositive = (isPositiveNumber == isPositive);

        ulong addNum = (ulong)(pAddNum * (isPositive ? 1 : -1));

        Unit.DivisionUnit divition = new Unit.DivisionUnit();

        int count = 0;

        while (addNum != 0)
        {
            divition.SetDivisionUnit(addNum, 10);

            if (powList.Count <= count)
            {
                isPositiveNumber = isPositive;
                powList.Add(0);
            }

            if (isSamePositive)
            {
                powList[count] += (byte)divition.Remainder;
            }
            else
            {
                powList[count] -= (byte)divition.Remainder;
            }

            addNum = divition.Quotien;
            ++count;
        }

        CheckOver(powList);
    }