diff options
author | Erik Schnetter <schnetter@gmail.com> | 2013-03-21 23:56:19 -0400 |
---|---|---|
committer | Erik Schnetter <schnetter@gmail.com> | 2013-03-21 23:56:19 -0400 |
commit | 426f02cd14671a15424420adb9ba5735780e1c97 (patch) | |
tree | 9171b6357b8ca2d406405480f3c544316ae8e17c /vec_pseudo.h | |
parent | 9420f154df04f53c85720cfed3262bb67a040f0d (diff) | |
download | vecmathlib-426f02cd14671a15424420adb9ba5735780e1c97.zip vecmathlib-426f02cd14671a15424420adb9ba5735780e1c97.tar.gz |
Correct ilogb(0)
Diffstat (limited to 'vec_pseudo.h')
-rw-r--r-- | vec_pseudo.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/vec_pseudo.h b/vec_pseudo.h index 31d9cbb..ad3a70c 100644 --- a/vec_pseudo.h +++ b/vec_pseudo.h @@ -680,7 +680,12 @@ namespace vecmathlib { intvec_t ilogb() const { intvec_t res; - for (int d=0; d<size; ++d) res.v[d] = std::ilogb(v[d]); + for (int d=0; d<size; ++d) { + int_t r = std::ilogb(v[d]); + if (r == FP_ILOGB0) r = numeric_limits<int_t>::min(); + else if (r == FP_ILOGBNAN) r = numeric_limits<int_t>::max(); + res.v[d] = r; + } return res; } boolvec_t isfinite() const { return mapb(std::isfinite); } |