diff options
author | Erik Schnetter <schnetter@gmail.com> | 2013-07-03 11:52:01 -0400 |
---|---|---|
committer | Erik Schnetter <schnetter@gmail.com> | 2013-07-03 11:52:01 -0400 |
commit | 0d0ff36413872b25441dabaf645d5759ad43445c (patch) | |
tree | a272dab284b0093f96f95aee2c411a25ec6b0fe0 /vec_sse_float1.h | |
parent | a7cb8c1562a53bf7af68b9b872684f432d960716 (diff) | |
download | vecmathlib-0d0ff36413872b25441dabaf645d5759ad43445c.zip vecmathlib-0d0ff36413872b25441dabaf645d5759ad43445c.tar.gz |
Correct some frexp/ilogb implementations
Diffstat (limited to 'vec_sse_float1.h')
-rw-r--r-- | vec_sse_float1.h | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/vec_sse_float1.h b/vec_sse_float1.h index 6aa42dc..d3039ad 100644 --- a/vec_sse_float1.h +++ b/vec_sse_float1.h @@ -419,14 +419,25 @@ namespace vecmathlib { return to_float(_mm_min_ss(from_float(v), from_float(y.v))); } realvec fmod(realvec y) const { return std::fmod(v, y.v); } - realvec frexp(intvec_t& r) const { return MF::vml_frexp(*this, r); } + realvec frexp(intvec_t& ir) const + { + realvec r = std::frexp(v, &ir.v); + if (isinf()) ir.v = std::numeric_limits<int_t>::max(); + if (isnan()) ir.v = std::numeric_limits<int_t>::max(); + return r; + } realvec hypot(realvec y) const { return MF::vml_hypot(*this, y); } intvec_t ilogb() const { int_t r = std::ilogb(v); typedef std::numeric_limits<int_t> NL; - if (FP_ILOGB0 == NL::min() and r == FP_ILOGB0) r = NL::min(); - else if (FP_ILOGBNAN == NL::max() and r == FP_ILOGBNAN) r = NL::max(); + if (FP_ILOGB0 != NL::min() and *this == RV(R(0.0))) { + r = NL::min(); +#if defined VML_HAVE_NAN + } else if (FP_ILOGBNAN != NL::max() and isnan()) { + r = NL::max(); +#endif + } return r; } boolvec_t isfinite() const { return std::isfinite(v); } |