Monday, 25 June 2012

Creating A Binary Abacus


Dr. Emmett L. Brown: “Please excuse the crudity of this model, I didn't have time to build it to scale or to paint it.”
Every once in a while, it helps me to do something that is totally unrelated to the field of Software Design. In my case I like to make the occasional wooden thing. In this case, related to my previous blogpost, I decided to build a binary abacus.

Just to elaborate, a binary abacus is a abacus where each row has only one bead (which simplifies the design, even if it complicates the arithmetic for normal people). A picture of an abacus with all eight beads live, giving a maximum value of 255, is visible on the left.

Ingredients


  • some wood, 1.8 cm thickness
  • a cylindrical piece of wood, 15 mm thickness, 1 meter length which is too long, really.
  • a cylindrical piece of wood, 3 mm thickness, 1 meter length which is only just enough, so be carefull there
  • wooden beads, 15 mm diameter, exactly 8.
  • 4 or 6 screws (I used 40mm/3.5mm screws)

Utensils:
  • a hacksaw
  • old fashion woodsaw
  • glue (ended up not using it after all, depends on what you want)
  • sandpaper
  • tapemeasure (essential)
  • drill (3 mm and 4 mm)
  • pencil
  • screwdriver
  • paper
  • eraser
  • hammer

Schematic


The Making Of


Use the hacksaw to saw the cylindrical pieces of wood to the proper length. The support beams should be 11.5 cm. The bead rows should be 12.5 cm. Do not worry overmuch if the bead rows are a little too short or a little too long, a couple of mm isn't going to make much difference. Be careful though, the wood is quite brittle.

Cut up a piece of paper in the proper dimensions and then use that to indicate where to saw the wood, with the woodsaw.


Saw the wood into the proper shapes. You should end up with two identical rough wooden Trapezoids.

Drill the 16 3mm holes at 20 mm distances approximately 7 mm into the wood.

Drill the 4 (6) 4mm holes all the way through for the support beams.

Use the sandpaper on both the Trapezoids to get the rough edges off. Go nuts, the more the better the result.

Drill 3mm holes into the opposite ends of the two (or three) support beams, to guide the screws.

Erase all the pencil drawings you did on the wood.

Fix all the bead rows into place on one of the trapezoids. You should be able to do this using only your hands.

Add the support beams to the trapezoid.

Add the beads to the bead rows. Important! You don't want to find out that you have a perfect abacus but forgot to add the beads.

Have fun trying to get them properly aligned with the other trapezoid.

Screw support beams securely together, after everything seems properly fixed.

Small soft taps with a hammer (covered in cloth) to make sure the bead rows are secure.

Good luck!

Notes

Make sure that the beads can slide smoothly over the 3mm thick cylindrical piece of wood.

The hard part was getting all the rows to align properly against the holes in the wood.

I ended up using no glue at all, as the thing seemed pretty solid eventually.

Expansions


Possible extentions to the design are a red bead to indicate data overflow and some indications on the side on what's what. I was thinking along the lines of (from top to bottom) LSB 1, 2, 4, 8, 16, 32, 64, MSB 128.

In the example above, I used two supports at the bottom of the abacus. For maximum strength, you'd ideally wish to have a third support at the top somewhere.

And of course, some paint or some varnish will help.




Binary Abacus - Counting


Tuesday, 19 June 2012

Binary prefix

Apparently there's a new naming convention for amounts of bits and bytes.[1] One that I've never before heard of.

Apparently,
  • 1024 bytes is now called a kibibyte (KiB),
  • 10242 is now called a mebibyte (MiB) and
  • 10243 is now called a gibibyte (GiB)

However, Wikipedia does mention that it is not in much common use. Thank God.

References


[1] Binary prefix
http://en.wikipedia.org/wiki/Binary_prefix

Sunday, 10 June 2012

A (hopefully) simple Explanation of the Binary numeral system


Introduction


Hi! I am a software developer, and I can count to 32 with my fingers on just one hand.

Most people can count to 5 with their fingers.

How does that work? Well, imagine that you are counting with the fingers of your hand. Let's say you wish to indicate the number 1. No doubt you'd use your index finger. But it is of course also possible to use your thumb. When you think about it there are five different ways to indicate that you mean 1. This is terribly inefficient.

Instead of having 5 different ways to indicate the number 1, we can assign different numbers to the different fingers.

What you are, in fact, doing is no longer using how many fingers to determine the number, but which fingers.

This is what we all have been doing with the decimal system since we could count. When I ask you if there is a difference between the numbers 21 and 12, you say of course. But why is that? We are still using the same two digits, are we not? The answer is in the position of the two numbers.

The decimal system, the system we are dealing with every day, is called a positional notation with a radix of 10. The finger counting system explained above is called the binary numeral system, which is a positional notation with a radix of 2.

An Abacus

Whilst old people still know what an Abacus is, young people have no clue. An example of an Abacus using the Decimal numeral system that everybody knows is visible at the top of this article.

“The abacus is a device, usually of wood, having a frame that holds rods with freely-sliding beads mounted on them.”[1]

A Binary Abacus would look something like this[2]:

In the example above, one row on the abacus represents a “bit”, a value that is either 0 (no bead) or 1 (a bead). The combination of the 8 rows together make 256 combinations of beads possible. This is called a “byte”.

In the picture, all beads are "on", so the maximum value is displayed, 255.

Why?

Why do computers use a Binary numeral system? Why not have them use a Decimal numeral system, like we do? Wouldn't that make it easier?
That would make it easier for us, not easier for the computers. The reason for this is that computers are one of the most complicated machines we have. There are some advantages to computers dealing with binary numbers:
  • binary is easy for a computer, either it's on or off (yes or no, true or false, 1 or 0, electricity or no electricity). There's no ambiguity about it.
  • it is fault tolerant, which means that a computer can easily determine if the value was 1 or 0, even if there has been some problem. After all, there are only two options. If a transistor received 1.3 V instead of 1.5, the value is still a definite 1.
  • it is easier, no difficult hardware needs to be designed to take care of all the intermediate numbers we use like 5 and 6 and 3.

Note

When you think about it, the binary numeral system is also the smallest possible numeral system. Any less digits and you would not be able to count at all!

As you see, radix 2 means that a binary numeral system is always dealing with multitudes of 2. The numbers 1,2,4,8,16,32,64,128,256,512,1024 are numbers any Software Designer knows by heart. It also explains why a number of things dealing with computers are always expressed in multitudes of 2. Examples of these are the 32bits and 64bits processors and the need to always express memory in multitudes of 1024 instead of the 1000 we are used to.

An in depth article and the history of the binary numeral system is available at Wikipedia.[3]

Also, if anybody has any other insights to add to this article, I'd welcome it. I consider this article to be in permanent development.

Appendix A

The following numeral systems are currently in use:

nameradixused
binary2often
octal8rarely/none
decimal10most used
hexadecimal16heavily

Appendix B

The multitudes of 2:

number of bitsunitcomments
1bitoften
2--
4nibble, nybble or even nyble, semioctethalf a byte, corresponds to a single hexadecimal digit. An example of “ha ha only serious”[4]
8byte,octetthe number of bits in a byte
16word, shortvery old processors were only 16 bits
32longprocessors
64-modern processors
128--
256--
512--
1024kiloas in kilobits and kilobytes
10242megamegabytes
10243gigagigabytes
10244teraterabytes

References


[1] A Brief History of the Abacus
http://www.ee.ryerson.ca:8080/~elf/abacus/history.html
[2] Creating A Binary Abacus
http://randomthoughtsonjavaprogramming.blogspot.nl/2012/06/creating-binary-abacus.html
[3] Binary numeral system
http://en.wikipedia.org/wiki/Binary_numeral_system
[4] Ha ha only serious
http://www.catb.org/jargon/html/H/ha-ha-only-serious.html