开发者

How is Google Calculator implemented?

开发者 https://www.devze.com 2022-12-24 05:06 出处:网络
When you search in Google \"100F to C\" how does it know to convert from Fahrenheitto Celsius? Similarly, conversion from d开发者_开发百科ifferent currencies and simple calculation.

When you search in Google "100F to C" how does it know to convert from Fahrenheit to Celsius? Similarly, conversion from d开发者_开发百科ifferent currencies and simple calculation.

What is the data structure used, or is it simple pattern matching the strings?


It's not exactly simple pattern matching. Evaluating the mathematical expressions you can enter is not trivial. For example, here's an algorithm that evaluates a math expression. That's just the evaluation, there's probably a lot of code to detect if it's even valid.

For the currencies conversion and other units, that's simple pattern matching.


it's simple pattern matching

try
100 kmh in mph = no calculation
100 kph in mph = 62.1371192 mph

0

精彩评论

暂无评论...
验证码 换一张
取 消