
1 Jul
2011
1 Jul
'11
4:50 p.m.
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?