示例#1
0
        public static int SmallerByAbsIsFirstOrSecond(MyBigNumber myNmbr1, MyBigNumber myNmbr2)
        {
            int         floatPstn1 = myNmbr1.FloatPointPosition;
            int         floatPstn2 = myNmbr2.FloatPointPosition;
            MyBigNumber longFloatPart, shortFloatPart;
            int         longFloatLngth  = 0;
            int         shortFloatLngth = 0;

            if (floatPstn2 > floatPstn1)
            {
                longFloatLngth  = floatPstn2;
                shortFloatLngth = floatPstn1;
                longFloatPart   = myNmbr2;
                shortFloatPart  = myNmbr1;
            }
            else
            {
                longFloatLngth  = floatPstn1;
                shortFloatLngth = floatPstn2;
                longFloatPart   = myNmbr1;
                shortFloatPart  = myNmbr2;
            }
            string longFltStr  = longFloatPart.PartDigits;
            string shortFltStr = MyBigNumber.AddNmbrZero(shortFloatPart.PartDigits, -1 * (longFloatLngth - shortFloatLngth));
            var    lsToEqual   = new List <string>(2);

            lsToEqual.Add(longFltStr);
            lsToEqual.Add(shortFltStr);
            MyBigNumber.IndentLengthWithZeroes(lsToEqual);
            bool smallerLong = MyBigNumber.FirstLineSmallerThanSecond(lsToEqual[0], lsToEqual[1]);
            int  resCmpr     = 0;

            if (smallerLong)
            {
                if (floatPstn2 > floatPstn1)
                {
                    resCmpr = 2;
                }
                else
                {
                    resCmpr = 1;
                }
            }
            else
            {
                if (floatPstn2 > floatPstn1)
                {
                    resCmpr = 1;
                }
                else
                {
                    resCmpr = 2;
                }
            }
            return(resCmpr);
        }