Beispiel #1
0
        private static Int32 FloorLog10(MiniRational x)
        {
            var e     = FloorLog10_Sub(x);
            var count = e;

            if (count > 0)
            {
                while (count > 0)
                {
                    x = x / 10;
                    --count;
                }
            }
            else if (count < 0)
            {
                while (count < 0)
                {
                    x = x * 10;
                    ++count;
                }
            }
            if (x < 10 && x >= 1)
            {
                return(e);
            }
            throw new ApplicationException();
        }
Beispiel #2
0
 private static int FloorLog10_Sub(MiniRational x)
 {
     if (x == 1)
     {
         return(0);
     }
     else if (x > 1)
     {
         Int32 count = 0;
         while (x >= 1)
         {
             x /= 10;
             ++count;
         }
         return(count - 1);
     }
     else
     {
         Int32 count = 0;
         while (x < 1)
         {
             x *= 10;
             --count;
         }
         return(count);
     }
 }