diff --git a/exprtk.hpp b/exprtk.hpp index 3e6f2b9..cde89f4 100644 --- a/exprtk.hpp +++ b/exprtk.hpp @@ -248,11 +248,6 @@ namespace exprtk return data_; } - inline operator const char* () const - { - return data_.data(); - } - private: std::string data_; @@ -417,6 +412,8 @@ namespace exprtk 10000000000000000.0, }; + static const std::size_t pow10_size = sizeof(pow10) / sizeof(double); + namespace numeric { namespace constant @@ -607,14 +604,13 @@ namespace exprtk return ((v < T(0)) ? std::ceil(v - T(0.5)) : std::floor(v + T(0.5))); } - template - inline T roundn_impl(const T v0, const T v1, real_type_tag) - { - // 0 <= index <= sizeof(pow10) - const int index = std::max(0,std::min(sizeof(pow10),(int)std::floor(v1))); - const T p10 = pow10[index]; - return T(std::floor((v0 * p10) + T(0.5)) / p10); - } + template + inline T roundn_impl(const T v0, const T v1, real_type_tag) + { + const int index = std::max(0, std::min(pow10_size - 1, (int)std::floor(v1))); + const T p10 = T(pow10[index]); + return T(std::floor((v0 * p10) + T(0.5)) / p10); + } template inline T roundn_impl(const T v0, const T, int_type_tag) diff --git a/exprtk_benchmark.cpp b/exprtk_benchmark.cpp index cce68ab..109f70b 100644 --- a/exprtk_benchmark.cpp +++ b/exprtk_benchmark.cpp @@ -249,7 +249,7 @@ struct native static inline T func13(Type x, Type y) { - return (x + (std::cos(y - std::sin(2 / x * pi)) - std::sin(x - std::cos(2 * y / pi))) - y); + return (x + (std::cos(y - std::sin(T(2) / x * pi)) - std::sin(x - std::cos(T(2) * y / pi))) - y); } static inline T func14(Type x, Type y) diff --git a/readme.txt b/readme.txt index 5fa2652..9fd0706 100644 --- a/readme.txt +++ b/readme.txt @@ -481,7 +481,7 @@ correctly optimize such expressions for a given architecture. $f41(x,y,z) | x * log10(y)-z $f88(x,y,z,w) | x*y^7 + z*w^7 $f42(x,y,z) | x * sin(y)+z $f89(x,y,z,w) | x*y^8 + z*w^8 $f43(x,y,z) | x * sin(y)-z $f90(x,y,z,w) | x*y^9 + z*w^9 - $f44(x,y,z) | x * cos(y)+z $f91(x,y,z,w) | (x and y) ? z + $f44(x,y,z) | x * cos(y)+z $f91(x,y,z,w) | (x and y) ? z : w $f45(x,y,z) | x * cos(y)-z $f92(x,y,z,w) | (x or y) ? z : w $f46(x,y,z) | x ? y : z $f93(x,y,z,w) | (x < y) ? z : w $f94(x,y,z,w) | (x <= y) ? z : w