
Boost : 
From: Dominique Devienne (ddevienne_at_[hidden])
Date: 20200117 13:03:13
On Fri, Jan 17, 2020 at 1:36 PM anshu khare via Boost
<boost_at_[hidden]> wrote:
> #include <iostream>
> using namespace std;
> #include <boost/multiprecision/cpp_dec_float.hpp>
> using boost::math::constants::pi;
> using boost::multiprecision::cpp_bin_float_50;
>
> int main() {
> cout << cos(3 * pi<cpp_bin_float_50>/2) << endl;
> cout << cos(5 * pi<cpp_bin_float_50>/2) << endl;
> cout << cos(7 * pi<cpp_bin_float_50>/2) << endl;
> cout << cos(9 * pi<cpp_bin_float_50>/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
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk