diff options
author | Erik Schnetter <schnetter@gmail.com> | 2012-12-01 16:08:57 -0500 |
---|---|---|
committer | Erik Schnetter <schnetter@gmail.com> | 2012-12-01 16:08:57 -0500 |
commit | 471686ed980d1068aa5e5c8fb8289f8f81d33d39 (patch) | |
tree | c02940e1ca726573a20d117ca008fa50ea8c8039 /mathfuncs_convert.h | |
parent | af41d3bc35d082cb4d8e793071a801b589978ce8 (diff) | |
download | vecmathlib-471686ed980d1068aa5e5c8fb8289f8f81d33d39.zip vecmathlib-471686ed980d1068aa5e5c8fb8289f8f81d33d39.tar.gz |
Implement sin, make optimised builds work
Diffstat (limited to 'mathfuncs_convert.h')
-rw-r--r-- | mathfuncs_convert.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/mathfuncs_convert.h b/mathfuncs_convert.h index 852c94e..ea39e05 100644 --- a/mathfuncs_convert.h +++ b/mathfuncs_convert.h @@ -42,6 +42,10 @@ namespace vecmathlib { realvec_t fhi = as_float(xhi) - RV(FP::as_float(exponent_hi)); // add largest negative number again fhi -= RV(R(FP::sign_mask)); + // Ensure that the converted low and high bits are calculated + // separately, since a real_t doesn't have enough precision to + // hold all the bits of an int_t + fhi.barrier(); // Combine results return flo + fhi; @@ -90,9 +94,11 @@ namespace vecmathlib { realvec_t mathfuncs<realvec_t>::vml_round(realvec_t x) { realvec_t r = fabs(x); + // Round by adding a large number, destroying all excess precision real_t offset = RV(std::scalbn(R(1.0), FP::mantissa_bits)); r += offset; -#warning "TODO: don't optimise this away!" + // Ensure the rounding is not optimised away + r.barrier(); r -= offset; return copysign(r, x); } |