C++ Mathematical Expression Library (ExprTk) http://www.partow.net/programming/exprtk/index.html

This commit is contained in:
Arash Partow
2013-09-12 23:28:40 +10:00
parent f2de4424d3
commit f28fd418b5
3 changed files with 38 additions and 36 deletions

View File

@ -610,7 +610,10 @@ namespace exprtk
template <typename T>
inline T roundn_impl(const T v0, const T v1, real_type_tag)
{
return T(std::floor((v0 * pow10[(int)std::floor(v1)]) + T(0.5)) / T(pow10[(int)std::floor(v1)]));
// 0 <= index <= sizeof(pow10)
const int index = std::max<int>(0,std::min<int>(sizeof(pow10),(int)std::floor(v1)));
const T p10 = pow10[index];
return T(std::floor((v0 * p10) + T(0.5)) / p10);
}
template <typename T>
@ -8933,6 +8936,8 @@ namespace exprtk
}
map.clear();
}
size = 0;
}
template <typename Allocator,