On Fri, Jan 17, 2020 at 1:36 PM anshu khare via Boost
#include <iostream> using namespace std; #include
using boost::math::constants::pi; using boost::multiprecision::cpp_bin_float_50; int main() { cout << cos(3 * pi
/2) << endl; cout << cos(5 * pi /2) << endl; cout << cos(7 * pi /2) << endl; cout << cos(9 * pi /2) << endl; return 0; } Output is as follows:
1.06911e - 50 1.06911e - 50 -1.06911e - 50 1.06911e - 50
I'm not much of a math person, but what's a "highly negative value" to you? PI/2 is 90 degrees, and the cosine of odd multiples of 90 degrees is zero (0). And you're getting values very very close to zero, on one side of it or the other, due to some numerical error/rounding I guess. Note the fabs() is John's code example. Whether the error delta is + or - doesn't matter, it's still within 2 epsilon, and "OK" I guess. All seems "normal" here... --DD