boost::numeric::interval constructor seems not creating an interval enclosing its arguments
まだ誰も着手していません。
評価
調査の方向性
まず boost/numeric/interval.hpp、Boost 1.85.0、および -frounding-math を使って例を再現し、次にコンストラクターと += の動作を interval のドキュメントと比較します。観測された境界が文書化された丸めの保証と一致するかを判断し、これらのケースをカバーしている既存のテストを特定します。動作が説明され、必要な実装またはドキュメントの変更がテストでカバーされていれば完了です。
索引モデルが issue の本文から書いたものです。
説明
In the document of boost interval https://www.boost.org/doc/libs/1_86_0/libs/numeric/interval/doc/interval.htm#interval
If the interval constructor has only one argument, "The constructors create an interval enclosing their arguments."
But in the following code, seems not working like this, it just sets interval's upper and lower bounds as the same value of my input. This is NOT what we expect for interval arithmetic, since the input may not be precisely stored in a computer.
#include <iostream>
#include <boost/numeric/interval.hpp>
using namespace std;
int main() {
cout << setprecision(20);
boost::numeric::interval<double> I = boost::numeric::interval<double>(0.1);
cout << I.upper() << endl; // print: 0.10000000000000000555
cout << I.lower() << endl; // print: 0.10000000000000000555
}
another strange thing is when I add a double number, sometimes it gives the desired bound, but sometimes NOT! See below, adding 0.1 to the interval and adding 1.1 to the interval gives different type of the result. adding 1.1 gives the desired result.
#include <iostream>
#include <boost/numeric/interval.hpp>
using namespace std;
int main() {
cout << setprecision(20);
boost::numeric::interval<double> I = boost::numeric::interval<double>(0.1);
I += 0.1 // add 0.1
cout << I.upper() << endl; // print: 0.2000000000000000111
cout << I.lower() << endl; // print: 0.2000000000000000111
}
#include <iostream>
#include <boost/numeric/interval.hpp>
using namespace std;
int main() {
cout << setprecision(20);
boost::numeric::interval<double> I = boost::numeric::interval<double>(0.1);
I += 1.1 // add 1.1
cout << I.upper() << endl; // print: 1.2000000000000001776
cout << I.lower() << endl; // print: 1.1999999999999999556
}
When compiling I add -frounding-math, and the boost version is v1.85.0.
- 主要言語
- C++
- スター
- 31
- フォーク
- 49
- 平均マージ
- 2日 2時間
- マージ済み PR(30日)
- 3
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
boostorg/interval のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 10/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 45/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
boostorg/interval の issue をすべて見る
似ている issue
-
Component: Ruby Type: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
メンテナーはふだん 3 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
kokkos/kokkos-kernels#3328 ·
メンテナーはふだん 1 日以内に返信
-
bug needs triage tcp
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
project-chip/connectedhomeip#74644 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信