예제 #1
0
        public override Number DividedBy(Number other)
        {
            Number counter = new Zero();
            Number step    = other.Absolute();
            Number current = step;

            if (other.Sign().Equals(other.Sign().Invert()))
            {
                throw new System.Exception("Cannot divide by zero!");
            }

            while (GreaterThan(current) || Equals(current))
            {
                counter = counter.Next();
                current = current.Plus(step);
            }

            return(counter.Times(other.Sign()));
        }