StringToValue C++ class code for calculation string as mathematical expression.
by
Leonid Sakharov
Creation of flexible user interface could demand an implementation of capacity for user to input not just numbers but sophisticated mathematical formulas effectively permitting programming experience. Microsoft Excel is the most famous example of such program. MathCad also provide the feature. LeoCalculator and LeoStatistic of the author of these codes use exactly these codes on display here.
Downloadable zip file contains all necessary files to create project LeoCalculator (http://www.leokrut.com/leocalculator.html) with Visual C version 6 and higher. The class StringToValue provide pubic method Calculate(CString s) that return value of mathematical expression provided by in argument string.
Sample of usage:
#include "stringtovalue.h"
StringToValue stv;
CString s=”2.2*(1.63-exp(-4.2))”;
double v=stv.Calculate(s);
//v will be 3.55301
Codes are flexible to permit addition of custom functions with several arguments.
Provided materials are for educational and internal development usage only. Reselling codes or LeoCalculator are not permitted.
LeoKrut solely presented here by Leonid Sakharov is responsible only for claims made above. Additional service like teaching of usage, customization of the codes, translation into other programming language, adding custom function can be negotiated separately.