# Division

This page describes the contents of the file division.xls, which you can download below. The file contains a function to find remainders and three macros that do division.

In the file, a "small" number means it fits into one cell on a worksheet. A "big" number has to be entered one digit per cell. You can play with big numbers of up to 250 digits setting them out horizontally across the spreadsheet.

Remainder function
This is a simple function that tells you the remainder on dividing a big number by a small divisor.
In other words: function = bigNumber Mod smallDivisor.

## Long division - three versions

Version 1 divides a big number by a small divisor. It reads a digit of the big number, calculates and writes a digit of the answer. It keeps going until it reaches the end of the big number. It is pretty simple and contains no validation checks. It can't handle decimals, but you could write some code to do so if desired.

Version 2 also divides a big number by a small divisor. It reads the big number into a VBA array before beginning the calculation. As it reads the number, it checks the input. Each digit of the big number goes into a separate element of the array. This version can handle decimals in both the big number and the answer. The small divisor must be an integer. If you want a lot of decimals in the answer, it will wrap on to the next row. It also looks for recurring patterns in the decimals.

Version 3 divides a big number by another big number. Like version 2, it reads the big numbers into VBA arrays before beginning the calculation and does identical validation checks. Both input numbers can include decimals. It also looks for recurring patterns of decimals in the answer.

Interesting things to do
Although I keep referring to the "big" number, it is quite interesting to set it to 1. Enter different divisors and look at the recurring patterns of decimals.

Go into the VBA code and change where the answer wraps. For example, calculate 1/17 and set the answer to wrap at 32.

How much change to the VBA code is needed to carry out the division in another base (not base 10)?

Use the file to solve the "units fore and aft" puzzle. Download division.zip (49kb) home