diff options
author | Erik Schnetter <schnetter@gmail.com> | 2013-07-03 14:38:58 -0400 |
---|---|---|
committer | Erik Schnetter <schnetter@gmail.com> | 2013-07-03 14:38:58 -0400 |
commit | 862802c1eff0906c8469fd393a4100020467218a (patch) | |
tree | f9241f1fca7cc749e50e6256ac3ee8b64bc36235 /vec_pseudo.h | |
parent | a5b17dbe53dad4e548a41180d2e907601400c031 (diff) | |
download | vecmathlib-862802c1eff0906c8469fd393a4100020467218a.zip vecmathlib-862802c1eff0906c8469fd393a4100020467218a.tar.gz |
More ilogb corrections
Diffstat (limited to 'vec_pseudo.h')
-rw-r--r-- | vec_pseudo.h | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/vec_pseudo.h b/vec_pseudo.h index 1e78fb7..b8aa808 100644 --- a/vec_pseudo.h +++ b/vec_pseudo.h @@ -9,6 +9,7 @@ #include <algorithm> #include <cmath> +#include <climits> #include <string> #include <sstream> @@ -750,13 +751,14 @@ namespace vecmathlib { { realvec_t res; for (int d=0; d<size; ++d) { - int ir; - real_t r = std::frexp(v[d], &ir); + int iri; + real_t r = std::frexp(v[d], &iri); + int_t ir = iri; #if defined VML_HAVE_INF if (std::isinf(v[d])) ir = std::numeric_limits<int_t>::max(); #endif #if defined VML_HAVE_NAN - if (std::isnan(v[d])) ir = std::numeric_limits<int_t>::max(); + if (std::isnan(v[d])) ir = std::numeric_limits<int_t>::min(); #endif res.v[d] = r; ires.v[d] = ir; @@ -772,10 +774,14 @@ namespace vecmathlib { typedef std::numeric_limits<int_t> NL; if (FP_ILOGB0 != NL::min() and v[d] == R(0.0)) { r = NL::min(); -#if defined VML_HAVE_NAN - } else if (FP_ILOGBNAN != NL::max() and std::isnan(v[d])) { +#if defined VML_HAVE_INF + } else if (INT_MAX != NL::max() and std::isinf(v[d])) { r = NL::max(); #endif +#if defined VML_HAVE_NAN + } else if (FP_ILOGBNAN != NL::min() and std::isnan(v[d])) { + r = NL::min(); +#endif } res.v[d] = r; } |