Wild About Math! Making Math fun and accessible


How do calculators do arithmetic?

This article is different from others as it discusses my early experiences with microcomputer programming. The article is, however, very relevant to this Math blog because it hopes to inspire children of all ages to take a very hands-on approach to learning how calculators do arithmetic, and gives suggestions for pursuing a self-directed and very fruitful exploration into the subject. Teaching yourself how computers do arithmetic will give you a lifelong foundation for programming computers or for just understanding how computers work.

I was fortunate enough to grow up in the 1970's when microcomputers were just starting to become popular. As someone with a lifelong love of Math and an interest in computer programming I bought my first computer in the late 1970's. It was an Ohio Scientific Challenger 1P computer. It came standard with 4K of RAM. That's kilobytes, not megabytes or gigabytes. I remember plunking down a few hundred dollars to double the memory to 8K. A fun little exercise is to compare the cost of the extra 4K of memory (let's say it was $300) to the cost of 4 gigabytes of memory for a typical PC today, considering that 4GB is roughly 1 million times larger than 4KB. I say roughly, because 4GB is actually 1024^2 times larger than 4kB.

With such little memory available in my first PC I had to write programs that were pretty compact and I didn't have any of the advantages of high-level programming languages, although BASIC did come with the computer, in ROM, so it didn't take up the main RAM. I quickly discovered the challenges and pleasures of programming in something called machine language, which is a very close-to-the-ground approach to instructing a microcomputer. Using machine language I learned a tremendous amount about how computers (and calculators, which are simple computers) do arithmetic. That learning has served me remarkably well in a 25-year career in the computer industry. Unfortunately, low-level programming is becoming a lost art, relegated to a few college-level computer architecture classes and to a few programmers in the computer industry.

When I was growing up there were many hobbyists that were building and programming their own computers at a very low-level because the tools and memory to build sophisticated windows-based applications didn't exist or weren't affordable.

Being a curious person I wondered how calculators worked. What was going on in those chips to perform arithmetic? If computers use binary (0 and 1) for everything how come I could enter decimal numbers into the calculator and see decimal results? It turns out that one of the students I'm mentoring in Math has an interest in computer logic and we're exploring the logic and coding involved in building a simple computer. So, I've had the motivation to find resources to help in the exploration.

There are three basic approaches to learning about how calculators do Math. The first is to build a calculator. This can be done using a calculator chip, battery, and other components plus a case and keyboard. While this approach might be somewhat instructive, all of the logic is handled in the chip and there's not much to learn about computer logic. The second approach is to build a calculator but to use logic gates and circuits and connect them together instead of one do-it-all chip. This would be quite instructive but would require more comfort with computer electronics than I have. The third approach, which I'm taking, is to use a computer program to simulate the inner workings of the hardware and basic operating system inside a calculator and to guide my student to learning by having him do the programming required to have the calculator simulator recognize keystrokes, do arithmetic, and display results.

I found this very interesting web-site, DIY (Do It Yourself) Calculator, which I believe will be very usefulHow Computers Do Math in this exploration. The site promotes a book, The Definitive Guide to How Computers Do Math, which has laboratory explorations that guide students in programming their own arithmetic functions using the DIY Calculator simulator. I've ordered a copy of the book and will report back on its utility. I'm familiar with most if not all of the concepts discussed in the web-site so I believe the education provided by the book will be very valuable.

Another useful resource I've found is the Basic Logical Functions and Gates page, which links to another of other relevant pages. These pages can provide the background for someone wanting to understand how one can take the basic building blocks of calculators and computers (AND, OR, and NOT gates plus the associated Boolean logic) and design the logic circuits that ultimately perform any function that any computer can perform.

I highly recommend that anyone interested in both computers and Math take the time to learn how computers operate at the most basic level. I know this understanding has greatly enriched my life.

Filed under: Computers Leave a comment
Comments (7) Trackbacks (1)
  1. Ah … the good old days! I had a MicroBee with 16K RAM! What a hoot! It’s also interesting to remember that back then you actually needed to know quite a bit about the DOS commands to do anything useful, now … What is DOS??? Bloated software, hidden directories (err … sorry – folders) … the kids of today don’t really know much at all. I’m surprised the power switch isn’t bigger!! 🙂 Just kidding … not really …

  2. That’s great and all, but you haven’t told us how calculators do arithmetic.

  3. @Mad Hatter: I remember DOS pretty well. I even saw CP/M in action once or twice.

    @Joe: You’re right. I didn’t mean to mislead with the title. I’ll be writing more specifics over time. In the meantime, the DIY calculator site has lots of free information as does the logic site I referred to. And, once I have the book in hand I’ll know for sure if it’s helpful.

  4. And just for the record, I wasn’t being an ass. Just stating what I saw.

  5. DOS, CP/M, wow, old times!

    We had a TRS-80 with 16K RAM — that was the upgrade — the basic machine had only 4K. And don’t forget storing programs on cassette tape! And then trying to get the machine to read the programs back off the cassette tapes 😯

    After that I had a Kaypro.

    I didn’t do any machine language programming on the TRS-80 or the Kayrpo, but I did learn how to design counters and arithmetic operators from gates in college, and also did assembler programming there (and a touch in high school, using punch cards and a mainframe). I must say though, that all of that has been forgotten over time. 🙂

  6. @Joe: I hear you. I’ll pay more attention to the titles of my posts in the future. And, it’d be very very tough to really explain in one post how calculators do Math. But, it’s a fascinating subject, definitely worth exploring.

    @mathmom: I certainly remember the TRS-80. I had an Atari 800 which was of the same vintage. I also remember not having a hard drive and storing programs on casette tape. I also remember storing programs on paper tape! And I did do a little work with punch cards but not tons.

  7. Another book you might want to take a look at is “Inside Your Calculator : From Simple Programs to Significant Insights” by Gerald R. Rising (it’s expensive so you might want to get a library copy).

Leave a comment