Cosine rounding failure on macOS
- Dominant language
- C++
- Stars
- 31
- Forks
- 48
- PR merge metrics
- No merged PRs in 30d
Description
I am running into issues with the interval library when compiling with Clang. This is the simple failure case:
```c++
#include
#include
#include
typedef boost::numeric::interval<
double,
boost::numeric::interval_lib::policies<
boost::numeric::interval_lib::save_state<
boost::numeric::interval_lib::rounded_transc_std >,
boost::numeric::interval_lib::checking_base > >
Interval;
int main(int argc, char* argv[])
{
Interval theta = Interval(0.79358805865013693);
Interval output = cos(theta);
std::cout << std::setprecision(std::numeric_limits::digits10 + 1)
<< "[" << output.lower() << ", " << output.upper() << "]"
<< std::endl;
std::cout << "is empty: "
<< (output.lower() > output.upper() ? "true" : "false")
<< std::endl;
}
```
The output when compiled with clang is:
```
[0.7012920012119436, 0.7012920012119435]
is empty: true
```
You can see that the last digit was rounded improperly resulting in an empty interval. If I try the same case but use `rounded_transc_exact` for the rounding policy It works as expected:
```
[0.7012920012119437, 0.7012920012119437]
is empty: false
```
My compiler info is
```
Apple clang version 11.0.0 (clang-1100.0.33.17)
Target: x86_64-apple-darwin19.3.0
Thread model: posix
```
and the example is compiled in debug mode. The examples works fine on GCC (specifically I tested on `gcc (Ubuntu 9.2.1-9ubuntu2) 9.2.1 20191008`)
Is this an expected failure for Clang?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.