Addition in Other Bases

written by Teresa Carrigan



Top

WHAT IS IT?

This model demonstrates addition in any base from two to sixteen. It also illustrates the concept of overflow.

Top

HOW IT WORKS

The arrow adds one column of digits at a time, starting with the right-most column. If the sum is too large to be a digit in that base, then the base is subtracted from the sum and the arrow carries a one to the next column. If the arrow holds a carry when all the columns are processed, then overflow occurs (assuming the number of digits is fixed).

Top

HOW TO USE IT

The setup button generates a random addition problem. The base used is determined by the base slider, and then maximum number of digits for each number is determined by the number-of-digits slider.

The number-of-digits slider sets the number of digits that the count will hold the next time the setup button is pressed. Possible values range from two to ten.

The base slider sets the base to be used the next time the setup button is pressed. You may choose any base from two to sixteen.

The random button changes the values of the base and number-of-digits sliders and then sets up a new addition problem.

The slow-motion slider is an easy way to adjust the speed of the display so you can watch the digits change as the red arrow passes. Set it to zero if you want to just see the answer quickly.

The step button adds the next column of digits, and then stops so you can take notes.

The go button processes the remaining columns of digits, at a speed set by the slow-motion slider. This is useful when you do not need to take notes between each step, or do not wish to press the step button several times to get an answer. If you want to pause the demonstration, simply click the go button a second time and it will stop after it finishes the current step. You may then click go a third time to resume.

If the random-quiz? switch is on, then quiz questions can come from any base and any number of digits. If it is off, then quiz questions are generated from the base and number of digits specified by the sliders.

The quiz button will generate a random addition problem and ask you for the answer. For bases larger than ten, you do not need to capitalize digits that are letters. You are not required to pad leading zeroes to the correct number of digits, but do not include any overflow digit. Spaces and commas in your answer will be ignored, so use them freely to avoid copy errors.

The show-again button starts the exact problem from the beginning. You may then click either the step button or the go button to see the same demonstration.

Top

THINGS TO NOTICE

If there is a carry out of the left-most column, an overflow error occurs. This is because computers reserve a fixed amount of space for each integer. In working problems by hand, we can always add another digit to the left.

Top

THINGS TO TRY

Set the slow-motion to about .50 seconds (or slower) and press the step button a few times. Watch the red arrow as it processes each row.

Press setup or random until you see a problem with large digits in the left-most column. Press go to see if an overflow error is detected.

Top

EXTENDING THE MODEL

Modify the model to show fixed point representation; that is, specify a given number of digits to the right of the decimal place.

Modify the model to allow addition of more than two numbers.

Allow the user to input the two numbers to be added.

Display the decimal equivalent of the two addends and the sum.

Top

NETLOGO FEATURES

"ask other-digit-here" is used by the arrow to process the digit it is passing over.

Top

RELATED MODELS

Top

CREDITS AND REFERENCES

This model was written by Teresa W. Carrigan, 2004.

Permission to use, modify or redistribute this model is hereby granted, provided that both of the following requirements are followed:

  1. this copyright notice is included.
  2. this model will not be redistributed for profit without permission from Teresa Carrigan.
Contact Teresa Carrigan for appropriate licenses for redistribution for profit.

To refer to this model in academic publications, please use: Carrigan, T. (2004). Addition in Other Bases model. Blackburn College, Carlinville, IL.

In other publications, please use: Copyright 2004 by Teresa W. Carrigan. All rights reserved.

Top

FOR MORE INFORMATION

For more information about addition in other number bases and overflow detection, see one of the following textbooks:
  1. Null, L. and Lobur, J. Essentials of Computer Organization and Architecture, First Edition, Jones & Bartlett, pages 45-46; 53.
  2. Dale, N. & Lewis, J. Computer Science Illuminated Second Edition, Jones and Bartlett, pages 39-40; 62-63.


Home

Applets on this website were written by Teresa Carrigan in 2004, for use in computer science courses at Blackburn College, with the exception of the Fireworks applet. The applets made with NetLogo require Java 1.4.1 or higher to run. The applets made with NetBeans require Java 1.4.2 or higher to run. Applets might not run on Windows 95 or Mac OS 8 or 9. You may obtain the latest Java plugin from Sun's Java site.