Browse Source

Add "inf" as variable to param field expression parser.

tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
4ddd52d0f4
1 changed files with 11 additions and 4 deletions
  1. +11
    -4
      src/Quantity.cpp

+ 11
- 4
src/Quantity.cpp View File

@@ -31,10 +31,17 @@ std::string Quantity::getDisplayValueString() {
}

void Quantity::setDisplayValueString(std::string s) {
double result = te_interp(s.c_str(), NULL);
if (std::isfinite(result)) {
setDisplayValue(result);
}
static const double inf = INFINITY;
static te_variable vars[] = {
{"inf", &inf},
};
te_expr* expr = te_compile(s.c_str(), vars, LENGTHOF(vars), NULL);
if (!expr)
return;

double result = te_eval(expr);
te_free(expr);
setDisplayValue(result);
}

std::string Quantity::getString() {


Loading…
Cancel
Save