How does a calculator work?

How does the calculator built into Google search work?

  • Take this for example: ((one plus (one plus (nine divided by 3))) divided by 5) plus sqrt(28) How is Google search able to convert the numbers in word form to numerals, determine the order in which the operations will be executed, and perform several operations in just .15 seconds? Take this for example:one hundred fifty-two thousand five hundred nine plus 7 How does it determine that "one hundred fifty-two thousand five hundred nine" is a single number? How is everything that the calculator does done with such efficiency?

  • Answer:

    Google have some extremely complicated parsing algorithms to try to work out exactly what a query means, in order to try to find what you meant rather than what you said. In this case, the first stage is probably detecting that it looks like a mathematical expression. The only major terms are numbers and mathematical operators (whether words or symbols), and detecting numbers written out is not much more difficult than noticing digits. After all, they do have a fairly regular pattern. Once a query is identified as being a mathematical expression, it's easy to convert it into a calculation that gives an actual answer. This happens extremely quickly because Google have [a] some very good and very well-optimised algorithms for doing this, and [b] a lot of processing power built to do exactly this. As for determining that "one hundred fifty-two thousand five hundred nine" is a single number, I would imagine that's done by context: it recognises that the only words are numbers, and then attempts to parse the expression. A walkthrough of how this parsing might work could be: one: 1 hundred: 1x100=100 fifty-two: (no operator, so assume it's addition) 100+52=152 thousand: 152x1000 = 152000 five: (no operator) 152000 + 5 = 152005 hundred: (backtrack! they meant "500") 152000+(5x100) = 152500 nine: (no operator) 152500 + 9 = 152509 At least, that's more or less how I'd write it, to begin with.

Dave Ingram at Quora Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.