//Divides two InfInt's public InfInt Divide(InfInt divValue) { InfInt zero = new InfInt(); InfInt one = new InfInt("1"); InfInt ten = new InfInt("10"); //Numerator smaller than denominator if (this.CompareTo(divValue) == -1) { return(zero); } //Numerator == Denominator if (this.CompareTo(divValue) == 0) { return(one); } //Divide by zero if (divValue.CompareTo(zero) == 0) { Console.WriteLine("Oops, you tried to divide by zero!"); return(zero); } //Numerator larger than denominator int i = 0; InfInt returnValue = new InfInt(); InfInt tempThis = new InfInt(); while (i < DIGITS) { //Drop down a value int tempNumber = this.Integer[i]; string tempString = Convert.ToString(tempNumber); InfInt tempInfInt = new InfInt(tempString); for (int l = 0; l < DIGITS; l++) { tempThis = tempThis.Add(tempInfInt); //divValue divides into tempThis if (tempThis.CompareTo(divValue) >= 0) //See how many times divValue goes into tempThis { InfInt tempReturnValue = new InfInt("1"); while (divValue.CompareTo(tempThis.Subtract(divValue.Multiply(tempReturnValue))) <= 0) { tempReturnValue = tempReturnValue.Add(one); } returnValue.Integer[i] = tempReturnValue.Integer[DIGITS - 1]; tempThis = tempThis.Subtract(tempReturnValue.Multiply(divValue)); } tempThis.Positive = true; tempThis = tempThis.Multiply(ten); i++; } } if (Positive != divValue.Positive) { returnValue.Positive = false; } return(returnValue); }