Tuesday, April 04, 2006

A Bug in Excel!

For my Math 20 classes, I have developed a huge spreadsheet with many pages of activities, which also generates random tests.

While finishing up the page that generates versions of the first midterm, I found a bug in Excel! (I use Excel 2002, Service Pack 3.)

I've been using Excel since my elementary school days. It has always been a great program. As much as various Windows operating systems have bothered me, part of me could never really villify the company that so nicely refined the spreadsheet. And, in all those years, I've never once seen it have a bug, or act up for a reason that was not actually my fault as the user -- until today. I feel stangely disappointed and triumphant, as if I caught my boss searching the web for naugty videos or something.

To see the bug, open an Excel spreadsheet, make sure the add-in "Analysis ToolPak" is enabled so the GCD function is enabled, and in the cells A1 and A2 enter the following:
  • =6*0.018*1000
  • =GCD(A2,1000)
The first cell calculates to 108. The second cell find the greatest common divisor of that value and 1,000. It shows 1, even though the GCD should be 4 (and Excel knows this if you replace the formula in cell A1 with the number 108).

The bug happens again if you edit cell A1 and replace the six with a nine. The GCD of 162 and 1,000 is not 1 either!

Very strange...