X

The correctly incorrect Spotlight calculator

Spotlight's calculator function can be useful, but the results may sometimes be slightly incorrect depending on how certain calculations are formulated.

Topher Kessler MacFixIt Editor
Topher, an avid Mac user for the past 15 years, has been a contributing author to MacFixIt since the spring of 2008. One of his passions is troubleshooting Mac problems and making the best use of Macs and Apple hardware at home and in the workplace.
Topher Kessler
2 min read

The Spotlight menu in OS X is an exceptionally useful feature for quickly finding documents by either file name or by content, but in addition it can be used as a launcher for applications and a way to quickly find Web pages you recently visited or items in your e-mail accounts, and in Leopard and Snow Leopard can be used to perform simple calculations. While for the most part the calculations work, sometimes there are odd behaviors that can give strange results.

For instance, if you take a number and divide it by a second number, then multiply the result by the second number, you should end up with the same number you started with:

Incorrect Spotlight Calculation
The first form of the equation gives an incorrect answer.

55 / 3 * 3 = 55

Any mathematician would agree the following function also yields the same results and is in principle the same calculation:

55 * (3 / 3) = 55

If you run both of these in the OS X Calculator application you will get "55" as a result, which makes sense; however, only the second one will give you "55" as the answer when you run them in the Spotlight menu. While the second one will be calculated properly, the first equation will give you "54.999999999" as the answer, which for most purposes is the same as 55, but is not in fact the same number.

Correct Spotlight Calculation
The second form of the equation shows the correct answer.

The reason for this is a simple oversight in the programming when managing infinite decimal places in a number. When divided by three, the resulting number has an infinite number of decimal places, and every computer will have to round off the digits at some point. Both the Calculator and Spotlight calculate more decimal points than they display onscreen, and both have a point at which they round the number of decimal points up or down; however, Spotlight rounds off numbers to what it displays onscreen after each part of the entered calculation, which makes it so the number of decimal points required for rounding is not met when the final answer is displayed.

Overall this is a trivial issue and not one that will significantly affect anybody, but it is amusing to see the answer to a simple calculation come out as incorrect, albeit "correct enough."



Questions? Comments? Have a fix? Post them below or e-mail us!
Be sure to check us out on Twitter and the CNET Mac forums.