Posts

Showing posts from March, 2014

A Calculator

Image
A calculator . So simple, yet, so powerful. Calculators have been around for a long time, and Bing provides one of the best Calculators out there on the web better than Google’s: http://www.bing.com/search?q=42*35     Now, let’s suppose that you want to validate the code behind a calculator. What you really want are two things: 1) A generator of well-formed mathematical expressions 2) An evaluator (an oracle) of mathematical expressions   The first is needed to generate a vast battery of test cases. The second is needed to compare the results against what the calculator is giving you (fight fire with fire!). This post is focusing on the former. The latter can be accomplished thru a variety of different means: a) Use another well-known engine as the oracle, such as WolframAlfa (cool) b) Use off-the-shelf tools to evaluate mathematical expressions (cooler) c) Write your own! (coolest!)   The idea to generate a valid math expres...