• On MovieTome: See the villain of IRON MAN 2!
August 25, 2008 12:34 PM PDT

Google's calculator muffs some math problems

by Stephen Shankland

Updated at 7 p.m. PDT with Google comment.

Google's calculator has troubles with some large numbers.

Google's calculator has troubles with some large numbers.

(Credit: Google)

Google's calculator has some trouble handling math with some large numbers, an issue that's not unheard of in computing circles but that might not sit well at a supremely nerdy company that's named after a humongous number.

The errors appear, though not consistently, with some very large numbers. For example, 2,999,999,999,999,999 minus 2,999,999,999,999,998 should be 1, but Google calculator shows it as 0.

It's not a simple case of a cutoff where things fall apart, though. 1,999,999,999,999,999 minus 1,999,999,999,999,995 incorrectly equals 0, but 1,999,999,999,999,999 minus 1,999,999,999,999,993 correctly equals 6. And 400,000,000,000,002 minus 400,000,000,000,001 incorrectly equals 0, but 400,000,000,000,002 minus 400,000,000,000,000 correctly equals 2.

Perhaps most amusing for the schadenfreude crowd, Google botches some math involving a googol, which is 1 followed by 100 zeros. The quantity of a googol plus one, minus a googol, equals 0 rather than the correct result, 1.

Cutting Google some slack
To be sure, math is difficult at this scale, where special methods for encoding numbers must be used if fine precision is to be maintained. Happily for those building calculators, though, it's a relatively unusual requirement in the real world: when measuring numbers on the magnitude of the distances between stars, it's rare that precision of a few centimeters can be obtained. And it's also rare that such precision actually is relevant.

Big numbers are often expressed with a two-part floating-point format, with some small number (the mantissa) multiplied by 10 to some power (the exponent). For example, Google's revenue in the second quarter was $1.25 billion, which also can be expressed as $1,250,000,000, or as $1.25 times 10 to the power of 9, or as $1.25 x 10^9. Floating-point math is good at spanning vast ranges of numbers, but typically the first component only keeps track of limited number of digits, so the small change falls by the wayside.

Precise math on computers is compounded by the fact that computers typically work in binary math, with digits of only 0 or 1, whereas people operate in decimal math, with digits running from 0 through 9. Accuracy is compromised when computers convert numbers into binary for processing, then back to base 10 to show us the results.

Indeed, even with decades of computing technology already under our belts, it wasn't until IBM's latest flagship Power6 processor that even Big Blue could do actual decimal math without converting into binary and back.

Ordinary calculators quickly run out of steam when trying to deal with large numbers. Sure, Google may have some issues, but most handheld calculators don't even let you type the number 1,999,999,999,999,993 much less do some mathematical operation on it. And there's not a big market for software such as Wolfram Research's Mathematica that can get the math right.

Google acknowledged its math is imperfect. "We are aware that the calculator tool in Google Web search is not working properly for certain calculations, and we are looking into this problem further. We apologize for any problems that this causes our users," the company said in a statement.

So big math is deceptively difficult. Should Google be forgiven for shortchanging us a bit when it comes to significant digits?

No, Google should do better
Nah. Any company that named itself after a big number must be held to a higher standard.

It might slow down calculations fractionally if Google had to detect when a large but high-precision number was involved, then send that calculation to a different server equipped with a more advanced math algorithm. And Google is rightly focused on server response, since users search more when the search engine is faster. But this issue is part of Google's core culture and image. Google muffing the math is like a politician wrapping himself in a flag that's got an extra couple stars.

After all, this is the company that decided to raise $2,718,281,828 billion in its IPO, a reference to "e," the base of natural logarithms, and that invited job applicants who could solve a math puzzle.

Ideally, Google could fix the algorithm. That's what Microsoft did with a recent Excel math problem and Intel did--at great expense--with the notorious FDIV bug that afflicted some Pentium processors in the 1990s.

Others have found limits with Google's calculator. For example, 2.00135558564^1023 is interpreted by Google's calculator as 1.79769313 x 10^308. But increase that number by one eensy little amount to 2.00135558565^1023, and Google interprets it as a search, not a math problem.

Which leads me to my final thought. In that last example, Google punts on the math and shows a mere search result, which isn't likely to lead anyone astray. It's what's called a graceful failure mode. It's better to show no results than bad results. That's especially important given that the very calculations where people would use a calculator are the very ones where, unlike the examples above, people aren't going to notice an error.

(Via Google Blogoscoped.)

Originally posted at Digital Media
Stephen Shankland writes about a wide range of technology and products, but has a particular focus on browsers and digital photography. He joined CNET News in 1998 and since then also has covered Google, Yahoo, servers, supercomputing, Linux and open-source software, and science. E-mail Stephen, or follow him on Twitter at http://www.twitter.com/stshank.
Recent posts from Webware
Firefox 3.5 and the potential of Web typography
Sites that help you lodge complaints
Google App Engine misfires
Microsoft: Bing needs to improve when news breaks
Google finally sued by makers of Finally Fast
Google Toolbar for IE speaks your language
Bing brings out the tweets
Google Search optimized for a mess of phones
Add a Comment (Log in or register) (16 Comments)
  • prev
  • 1
  • next
by brianld August 25, 2008 1:36 PM PDT
Good find, and I agree that a company who names itself after such a large number should indeed be held to a higher standard. However, is anyone actually relying on Google for performing these types of computations? Wouldn't an actual scientific calculator be better, not relying on something which obviously has a varying degree of accuracy?
Reply to this comment
by mbelisle August 25, 2008 2:03 PM PDT
After all, this is the company that decided to raise $2,718,281,828 billion in its IPO, a reference to "e," the base of natural logarithms, and that invited job applicants who could solve a math puzzle.

Wow! That sure is a lot of billions! With that kind of money, Google could buy the world economy!
Reply to this comment
by ewill3 August 25, 2008 2:33 PM PDT
I'm mildly surprised at this limitation. If one uses basic 8-byte doubles, the values 9 007 199 254 740 992 (2^53 or maybe 0x4340000000000000, if one prints out the actual bytes in hexadecimal) and 9 007 199 254 740 993 are indistinguishable without longer precision arithmetic; the last bit basically falls off the mantissa, as one can readily verify using a fairly simple program. However, the above values is nowhere near these (it's 5 * 10^14 in scientific shorthand). It turns out 350 000 000 000 000 - 349 999 999 999 999 = 0, but surprisingly 281 474 976 710 658 - 281 474 976 710 657 = 1 (aka (2^48+2) - (2^48+1)) and 300 000 000 000 000 - 299 999 999 999 999 = 1 as well. I'm not about to narrow it down further, though will note that 3.00000000000000 - 2.99999999999999 = 1.02140518 * 10^-14, as opposed to the more correct 1 * 10^-14; those stray bits are erroneous but may leave a telltale as to exactly what they're doing (1.02140518 * 10^-14 is just a smidge under 23 * 2^-51, it turns out).

Just as a sanity check, the mass of a proton can be expressed as 167 262 171. * 10^-35 kg (note the unusual position of the decimal point, as I put it there to get an integer); therefore Google's precision issues are well outside those needed for even the most precise of scientific work. 3 * 10^14 is more than enough to count the number of millimeters from Sol to Earth twice over (1 AU = 1.4960 * 10^11 m).
Reply to this comment
by lndsdotnet August 25, 2008 3:28 PM PDT
Google is using 32 bits for their floating point (float type in c), check the source code of a program I had posted in my blog, it's a testing of the most plausible cause of the bug:

http://www.lnds.net/2008/08/por_que_falla_la_calculadora_de_google.html
Reply to this comment
by The_Decider August 25, 2008 6:16 PM PDT
If they are using C, then they aren't too bright.

Python and Ruby make it absolutely trivial to calculate basic arithmetic operations and expand memory usage as needed.
by Pishkado August 25, 2008 5:20 PM PDT
"Indeed, even with decades of computing technology already under our belts, it wasn't until IBM's latest flagship Power6 processor that even Big Blue could do actual decimal math without converting into binary and back."

Someone is apparently too young to know computing history and didn't bother to check the facts. IBM computers did decimal math quite nicely as far back as the 1950s. For much of that time, up to the mid-60s, it had two parallel product lines: a "scientific" line that did binary (but not decimal) arithmetic in hardware, and a "commercial" line that was the other way around. (It had binary circuitry for memory addressing, but it wasn't user-visible via the machine-level instruction set.) The two lines merged in the April 1964 announcement of System/360, which could do both. Its successors are sold today as the zSeries.
Reply to this comment
by halftechie August 25, 2008 5:26 PM PDT
MSN / Live search returns right results

http://search.live.com/results.aspx?q=400000000000002-400000000000001&FORM=ADDLVD&src=
Reply to this comment
by halftechie August 25, 2008 5:27 PM PDT
MSN / Live search returns right results

http://search.live.com/results.aspx?q=400000000000002-400000000000001&FORM=ADDLVD&src=
Reply to this comment
by The_Decider August 25, 2008 6:19 PM PDT
If you need to perform basic math operations it is downright trivial to do it in Python or Ruby since they have no problems dealing with numbers greater the 2^32, unless that is all the memory you have.
Reply to this comment
by Imalittleteapot August 25, 2008 6:34 PM PDT
Not saying that Google doesn't have a bug here, but one mistake the author may be making in general is to suggest Google returns 0 when it should be equal to 1. When dealing with floats or huge numbers you should get the thought of equality out of your head as soon as possible, or at least the type of equality that is a==b. Instead of telling yourself it should be equal to you should think it should be close to. It should be close to a range or a given accuracy that you can define and then tune for when writing your code.

Another problem is computers like to throw numbers away. Humans like to round up. Computers don't care to round at all. In fact they prefer to truncate and just throw numbers away unless you code it not to. If it's throwing numbers away, especially in a loop, then you'll need to deal with that too.

Anyway, I'm going to look at lndsdotnet's code now to see what they think the deal with this particular bug is, but it might help if you think about it like this. Google shows that an unknown number that equals zero after truncating it should be close to 1. They probably just let the computer handle it how the computer wanted and that's not the best thing to do.
Reply to this comment
by slecalvez August 25, 2008 8:01 PM PDT
If this was Microsoft, it would've been harshly criticized.... But it's Google, which is all about the hype.
Reply to this comment
by Imalittleteapot August 25, 2008 8:26 PM PDT
Google was criticized here. This whole article was a criticism. I just don't think you noticed because you didn't read the comments carefully enough. Google has been getting criticized more and more too. Didn't you pay any attention to the street view debacles?

Neither Microsoft or Google is going to get criticized on this as hard as other things because this is a problem inherent to how computers work in general. This is not just a Google problem or a Microsoft problem. So, you'd get a completely different type of criticism than you would in situations like when IE doesn't follow standards just because.

Similar things have went wrong with Microsoft products too, but the biggest complaints about Microsoft are usually closed source, wasted resources, and security. Hardly ever does anyone claim that Microsoft can't subtract.

The problem isn't that Google is not getting criticized. The problem is that when they do get criticized you just don't happen to be around because of your bias. Both companies get complained about plenty enough.
by i_am_still_wade August 26, 2008 9:41 AM PDT
Question: WHO USES GOOGLE TO DO MATH!!!!!! Calculator programs are as common as dirt, and people are using Google to do math?
Reply to this comment
by gauravakagary August 26, 2008 11:48 AM PDT
seriously...who uses google for maths??? and why would someone do that??
Reply to this comment
by just_me_here September 19, 2008 10:28 AM PDT
I'm a huge fan of Google, and of Edward Kasner, who popularized the term "googol". But you are all wet on this calculation thing.

First of all, "google" <> "googol". Since the name is based on a well-meaning misspelling, I'd say that lets them off the hook. Particularly on calculations that would interest almost nobody. You are just being silly. No other ideas for an article?

Your comparison with Intel and Microsoft is also way, way off. Both are in the business of calculation. Google's business is not calculation. Nobody is calculating a rocket trajectory with a search engine.

Who cares about absurd precision? Nobody. This is just a ho-hum excuse for writing an article, and nothing else.
Reply to this comment
by jerthy35 March 15, 2009 10:31 AM PDT
Schanderfude on botched calculations highly unusual and unnatural numers. I guess someone needs to get a life.
Reply to this comment
(16 Comments)
  • prev
  • 1
  • next
advertisement

About Webware

Say No to boxed software! The future of applications is online delivery and access. Software is passé. Webware is the new way to get things done.

Add this feed to your online news reader

Webware topics

Making sense of Windows 7 upgrades

faq The basics and the fine print on Microsoft's options for those eyeing the next operating system from Redmond.
• Full Windows 7 coverage

Road Trip 2009: Big Sky Country

CNET News reporter Daniel Terdiman takes his car full of gadgets to the Rockies and the Great Plains in search of tech, science, nature, and more.
• America's Fortress: Cheyenne Mountain

advertisement

Inside CNET News

Scroll Left Scroll Right