# Activities/Abacus

## Using Abacus

### Clearing the abacus

Before you start an arithmetic operation, you need to "clear" the abacus. The upper beads should be positioned against the top of the frame and the lower beads should be positioned against the bottom of the frame. This is the default position for the abacus when you launch the activity.

Note that some of the abacuses (e.g., the schety) do not have any upper beads. In such cases, all of the beads should start in the down position.
Also note that the Clear Button on the main toolbar will also clear the abacus for you.

In each column, the bottom beads represent 1s and the top beads represent 5s. (The exception is the column in the schety with only 4 beads. These are 1/4 each.) So for each bead you raise up from the bottom in a column add 1 and for each bead you lower from the top in the same column, add 5.

The columns themselves represent decimal positions from right to left, e.g., 1s, 10s, 100s, 1000s, etc. (There are some exceptions: (1) the nepohualtzintzin uses base 20, e.g., 1s, 20s, 400s, 8000s, etc.; (2) on the schety, the beads to the right of the column with just four beads are 0.1s, 0.01s, 0.001s, and 0.0001s; the black beads on the Caacupé abacus are fractions; and the custom abacus lets you choose whatever (integer) base you want.)

The current value is always displayed on the frame. Experiment and you will quickly learn to write and read numbers.

Examples: In the gallery below, several simple examples are shown. In the gallery of images above, the number 54321 is shown on each of the different abaci.

Note: The display always assumes a fixed unit column, but you can override this choice.

To add, simply move in more beads to represent the number you are adding. There are two rules to follow: (1) whenever you have a total of 5 units or more on the bottom of a column, cancel out the 5 by sliding the beads back down and add a five to to the top; and (2) whenever you have a total of 10 units or more in a column, cancel out the 10 and add one unit to the column immediately to the left. (With the nepohualtzintzin, you work with 20 rather than 10.)

Example: 4+3+5+19+24=55

### Subtraction

Subtraction is the inverse of addition. Move out beads that correspond to the number you are subtracting. You can "borrow" from the column immediately to the left: subtracting one unit and adding 10 to the current column.

Example: 26–2–4–6–10=4

### Multiplication

There are several strategies for doing multiplication on an abacus. In the method used in the example below, the multiplier is stored on the far left of the abacus and the multiplicand is offset to the left by the number of digits in the multiplier. The red indicator is used to help keep track of where we are in the process.

### Division

Simple division (by a single-digit number) is the inverse of multiplication. In the example below, the dividend is put on the left (leaving one column vacant for the quotient) and the divisor on the right.

TODO: Add instructions for long division.

### Fractions

The fraction abacus lets you add and subtract common fractions: 1/2, 1/3, 1/4, 1/5, 1/6, 1/8, 1/9, 1/10, and 1/12, The fractional value is determined by the number of black beads on a rod, e.g., to work with thirds, use the rod with three beads, to work with fifths, use the rod with five beads.

The rods with white beads are whole numbers in base 10; from left to right 100000, 10000, 1000, 100, 10, and 1.

### The toolbars

From left to right:

project-toolbar button
see below
edit-toolbar button
see below
abacus-toolbar button
see below
customization-toolbar button
clear button
clear the abacus
stop button
exit the activity

From left to right:

copy
copy current value to clipboard
paste
paste a value from the clipboard into the abacus

From left to right:

decimal button
decimal abacus
soroban button
Japanese abacus
saupan button
Chinese abacus
nepohualtzintzin button
Mayan abacus
binary button
binary abacus
schety button
Russian abacus
fraction button
fraction abacus
Caacupe button
fraction abacus with +/–
rod button
Cuisenaire-like abacus
custom button

From left to right:

rods
select the number of rods:
select the number of beads on the top of the frame
bottom
select the number of beads on the bottom of the frame
factor
select the multiplication factor of top beads (e.g., on the Chinese abacus, each top bead counts as 5× the value of a bottom bead on the same rod)
base
select the base to determine the value of bottom beads across rods; this is 10 on most conventional abacuses, but 20 on the Mayan abacus, 16 on the hexadecimal abacus, and 2 on the binary abacus.
create
you must push this button to activate the selections you've made

## Learning with Abacus

• Using beads or pebbles, you can make an abacus. What is the difference between the abacus on the computer and a physical abacus?
• It is possible to create a custom abacus. I often use the example of Sumerian mathematics: the Sumerians counted on the digital bones (phalanges) of their fingers, so the base of their counting system was 12. All of the 12s (and 60s) we have in our mathemateics, e.g., 12 hours, 60 seconds, etc. have their roots in Sumerian math. But the Sumerians never invented an abacus. What would a Sumerian abacus look like?

## Extending Abacus

• A fun project is to compare calculations using Abacus with the Calculate Activity. Which is faster? Which is more accurate? Which is better for estimating? Which is better for comparing?
• Abacus supports paste, so you can take numeric values from other programs and paste them into the abacus to see what their representations are; for example, I often paste numbers into the hexadecimal abacus as a quick way of converting decimal to hexidecimal.
• Abacus also supports copy, so you can take a sum calculated on an abacus and export it into SimpleGraph or some other data-visualization Activities.
• A fun collaborative mode might be to have a number randomly selected and each sharer work independently to post it on the abacus of their choice first. There could be a tally of beads awarded for each correct answer.

## Modifying Abacus

Abacus is under GPL license. You are free to use it and learn with it. You are also encouraged to modify it to suit your needs or just for a further opportunity to learn.

• It might be good to have some of the above information in a Help palette, e.g., addition, subtraction, multiplication division.

Most changes can be confined to three modules: `AbacusActivity.py`, `abacus.py` and `abacus_window.py`. The former define the Sugar and GNOME toolbars; the latter defines what code is executed by each type of abacus.

Note: since a recent refactoring, these instructions are deprecated

For instance, to add a menu item such as 'Reset' you would do the following in `abacus.py`:

```       menu_items = gtk.MenuItem(_("Reset"))
```
• The _reset() method is trivial:
```   def _reset(self, event, data=None):
""" Reset """
self.abacus.mode.reset_abacus()
```

Similarly, you can add another button to the Sugar toolbar in `AbacusActivity.py`:

• Add these lines to the toolbar block:
```           # Reset the beads on the abacus to the initial cleared position
self.reset_button = ToolButton( "reset" )
self.reset_button.set_tooltip(_('Reset'))
self.reset_button.props.sensitive = True
self.reset_button.connect('clicked', self._reset_button_cb)
toolbar_box.toolbar.insert(self.reset_button, -1)
self.reset_button.show()
```
• The _reset_button_cb() method is trivial:
```   def _reset_button_cb(self, event, data=None):
""" Reset the beads on the abacus to the initial cleared position """
self.abacus.mode.reset_abacus()
```
• You'll have to create an icon for the button (`reset.svg`) and put it into the `icon` subdirectory of the bundle.

This will complete the changes in the `abacus.py`. The method `reset_abacus()` will have to be defined for each abacus in the `abacus_window.py`. This can be done by creating that method in the `AbacusGeneric` class used by all the varieties of abacus. The method may have to be overridden in some abacus subclasses for customization reasons. For instance, `reset_abacus()` was defined in `AbacusGeneric` class and then overridden in `Schety`.

If the changes involve modifying the graphics, then other methods may need to be modified as well. For instance, in order to introduce a reset button that can be clicked to reset the bead positions to the beginning, the following methods had to be modified – all in `abacus_window.py`:

1. in the `class Abacus`, method `_button_press_cb()` to activate reset button;
2. in the `class AbacusGeneric`, method `create()` to create the graphics for reset button;
3. methods `hide()` and `show()` to make the button visible.

## Reporting problems

If you discover a bug in the program or have a suggestion for an enhancement, please file a ticket in our bug-tracking system.

You can view the open tickets here.