What can a budding computer scientist learn from world religions? Number representation!
An important topic in computer science is the way we represent data; whether numbers, colours, images or sound. We need to choose a data representation that makes the tasks we need to do with the data easy. By choosing a good representation we can make the operations we want to do, so the algorithms we use, simpler or faster or take less memory, for example.
Take the way we represent numbers. Sometimes we just want to count with them. Other times we want to add them, yet other times multiply them. If we want to multiply numbers by 2 a lot then binary is good: you just add a 0 on the end. That operation is easy. It is much harder to do if you are using Roman numerals. Binary numbers also allow you to store large numbers fairly compactly and above all they work well when what you have to manipulate them are logic gates. The numbers used by the Ancient Egyptians, by contrast, with characters for 10, 100 and 1000 don’t take up too much space as long as the numbers don’t get too big. They are also fairly easy to add and subtract. Multiplication is much harder though. Choosing the right representation for the task at hand matters.
Another way to represent a number is called unary. Whilst our decimal system uses ten symbols: 0, 1 …, 9 to represent all numbers, unary uses just a single symbol, like 1, to do the same thing. In unary you just repeat that symbol the same number of times as the number you want to represent. So if I want to represent the number five then I can do that in unary by holding up 5 fingers or writing 11111 (as when making simple tally marks). To represent 6, I might hold up 6 fingers or write 111111. In the first case the single symbol I am using is a finger and in the second, I am using just the character, 1. This representation is very good for counting, especially for small numbers but can get unwieldy for longer ones.
The actual symbol or object I use doesn’t matter, so I can use shells or beads or even knots in a piece of string just as well. That is where religion comes in. In many religions it is important to count prayers or mantras, so keeping track of how many times you have said something matters. You need an easy and portable way to count, that allows you to keep track of where you are in the count while thinking of something else (the prayer). You therefore need an easy and portable number representation that doesn’t take up much thought. Unary, it turns out, is perfect for this.
Early Christian hermits, called the Desert Fathers, who lived in the deserts around Egypt, invented one such unary representation to help them count prayers, called a prayer rope. It helped them count the number of times they said an important prayer they repeated, called the “Prayer of the Heart”. They used a knot as their single symbol. The rope represented a number like 33, 50 or 100 by having that many knots in it. The person praying would say the prayer once for each knot, moving their fingers along the knots to keep count. When they got to the end of the rope, they had finished.
This led to the use of the Rosary in the Catholic Church. Now beads on the rosary are used to count through a particular sequence of prayers. The number of beads still stand for the number of prayers recited, but now, each prayers is different, as the person recites the sequence. Rosaries also change the representation slightly as the beads are grouped into 10s. This helps you keep track of where you are up to. It is like leaving a space after every 5 tally marks.
Misbaha and Islam
Muslims also use prayer beads, called Misbaha, to help them repeatedly chant the same thing, such as “Glory be to God” in praise of Allah. This is called the Tasbih. They are also used to count the 99 names of Allah. Misbaha therefore often have 99 beads so represent the number 99. Here the unary symbol is the bead. The original way the counting was probably done was using pebbles (so then the unary symbol was the pebble)., and this turned in to the more convenient string of beads.
Mala and Hinduism, Sikhism and Buddhism
Hindu’s, Sikhs and Buddhists, as well as other religions, also use prayer beads, this time often representing the number 108, as it is considered to be a special number. These prayer beads are called Mala or Japamala and probably derive from a version invented in China. They are used for counting the times the person has repeated a mantra or the name of a deity. For example a really simple, but important, Hindu mantra is “Om”. It stands for the ultimate consciousness. Having the mala to help is really important when chanting mantras, as the aim is to focus on the mantra alone, not on the numbers you are counting. The mala help that to happen be moving the count from the person’s head out into the world.
In all the religions variations of the simple unary representation have cropped up, such as having a different bead (ie a second symbol) to mark every 10th bead. Beads have the advantage over knots that they can slide along the string to help keep track of where in the count you are. One variation uses a cord with tassels that slides over the beads and can be left in place between any two beads. Now, if you are interrupted in the middle of repeating the mantra, you can easily carry on where you left off later. A tweak to the representation has made a new operation that was difficult to do before, suddenly very easy.
The right representation for the task at hand
The way we represent numbers is really important and getting the right representation can help us do the tasks we want or need to do more easily. Prayer knots and prayer beads are a really simple representation for numbers, designed to make one task simple: counting repetitions of prayers or mantras. If other operations were needed, like complex calculations, then the bead representation would not be very good. It is because the unary numbers embodied in prayer beads are perfect for counting, that this same representation has been invented multiple times and is used across so many of the world’s religions.
Whilst prayer beads aim to help humans do a task (counting) more easily, we similarly need to choose the best data representation when writing programs for computers to follow. Computers are general purpose which means the basic number representation has to be good for lots of different things, but especially in making it easy to do calculations using logic. It turns out a binary representation works really well for that. In each program we write we have to build new representations whether for images, or sounds, numbers or words. Choosing the right representation is critical.
With the right representation of numbers for the task, doing general purpose computation is easier for computers to do, but the right representation of numbers also makes being devout much easier for humans to manage too, as most religions have realised.
To make number representation tangible, make your own string of counting beads (not for wearing, just for counting), whether for prayer, mantra, mindfulness counting sheep to get to sleep or or just for counting.
Choose beads that are special to you or that just feel good to touch.
But remember it is a unary you are using.