Subject: [boost] returning floating point values from a metafunction
From: Kenny Riddile (kfriddile_at_[hidden])
Date: 2011-07-01 12:50:10
This isn't directly Boost-related, but this is still probably the best
place to ask this question. Just for fun, I was trying to write a
compile-time approximation of cosine using the following Maclaurin series:
cos( x ) ~= 1 - ( x^2 / 2! ) + ( x^4 / 4! ) - ( x^6 / 6! ) + ...
I ended up at a point where I needed to assign a const floating point
value to the result of an integer division, kind of like this:
static const float value = integerA / integerB;
My problem is of course that you can't cast to non integral/enum types
in a constant expression, which means that I end up with the truncated
result of integer division. Suggestions?