Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Cosine rounding failure on macOS

オープン
#25 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
cpp
領域
compilers

調査の方向性

まず Apple Clang で最小限の C++ 再現コードをコンパイルして実行し、その後 rounded_transc_std と rounded_transc_exact を比較します。boost/numeric/interval.hpp を通じて到達する区間実装と、その超越関数の丸めポリシーを読みます。Clang で cosine が境界の順序が正しい空でない区間を生成し、報告されている GCC の動作を維持できれば完了です。

索引モデルが issue の本文から書いたものです。

説明

I am running into issues with the interval library when compiling with Clang. This is the simple failure case:

#include <iomanip>
#include <iostream>

#include <boost/numeric/interval.hpp>

typedef boost::numeric::interval<
    double,
    boost::numeric::interval_lib::policies<
        boost::numeric::interval_lib::save_state<
            boost::numeric::interval_lib::rounded_transc_std<double> >,
        boost::numeric::interval_lib::checking_base<double> > >
    Interval;

int main(int argc, char* argv[])
{
    Interval theta = Interval(0.79358805865013693);
    Interval output = cos(theta);
    std::cout << std::setprecision(std::numeric_limits<double>::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?

主要言語
C++
スター
31
フォーク
48
平均マージ
1日 13時間
マージ済み PR(30日)
6

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

boostorg/interval のほかの issue

boostorg/interval の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。