`fmod` of `interval<long double>` can miss the true result
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
detail/c99sub_rounding_control.hpp、detail/ppc_rounding_control.hpp、detail/sparc_rounding_control.hppを読み、それらのto_int実装を、issueで言及されているAlphaおよびIA-64バックエンドと比較してください。interval<long double>を使ってfmodの例を再現し、変更後に結果が0を含むことを確認してください。
索引モデルが issue の本文から書いたものです。
説明
rounding_control<long double>::to_int calls rint, the double function, in three backends:
detail/c99sub_rounding_control.hpp, - Itsextern "C" { double rint(double); }is declared insidenamespace detail, so the templateto_int<T>always finds that one.detail/ppc_rounding_control.hppdetail/sparc_rounding_control.hpp
A long double with more than 53 significant bits is rounded to double before it is rounded to an integer. int_down and int_up then return wrong values, sometimes on the wrong side of the argument, and fmod, which uses int_down, returns an interval that does not contain the true result:
#include <boost/numeric/interval.hpp>
#include <iostream>
int main() {
typedef boost::numeric::interval<long double> I;
I r = fmod(I(1152921504606846977.0L), I(1)); // 2^60 + 1
std::cout << r.lower() << ' ' << r.upper() << '\n'; // must contain 0
}
It print 1 1 : godbolt
| Step | Expected | Actual |
|---|---|---|
x |
2^60 + 1 = 1152921504606846977, exact in long double (64-bit significand) |
same |
div_down(x, 1) |
1152921504606846977 (exact) | same |
to_int of that |
rintl(1152921504606846977) = 1152921504606846977 |
rint(double(1152921504606846977)): converting to double (53 bits) gives 1152921504606846976 = |
| 2^60 | ||
n = int_down(...) |
2^60 + 1 | 2^60 |
x - n * 1 |
1152921504606846977 − 1152921504606846977 = 0 | 1152921504606846977 − 1152921504606846976 = 1 |
result z |
[0, 0] |
[1, 1] |
The Alpha and IA-64 backends already declare rintl and use it in to_int(long double); doing the same in these three fixes it.
- 主要言語
- C++
- スター
- 31
- フォーク
- 49
- 平均マージ
- 1日 4時間
- マージ済み PR(30日)
- 9
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
boostorg/interval のほかの issue
-
PowerPC: `interval<long double>` with constant operands fails to compile with GCC対応中かも @reach2sayan が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
boostorg/interval#44 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 10/100
メンテナーはふだん 1 日以内に返信
-
Code behaves differently if compiled with MSVC vs GCC対応中かも @reach2sayan が 10 日前に担当しました。 オープン
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
boostorg/interval#35 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 45/100
メンテナーはふだん 1 日以内に返信
boostorg/interval の issue をすべて見る
似ている issue
-
bug-unconfirmed
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
Extended search mode does not find escape sequences (\t, \n, \r...)対応中かも @CyrilB1531 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 87/100
dail8859/NotepadNext#1181 ·
メンテナーはふだん 1 日以内に返信
-
A-tools P-low S-blocked task
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
☢️ Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
OpenAtomFoundation/pikiwidb#3309 ·
-
audit(c2): add_project_arguments('/experimental:c11atomics', language: ['c', 'cpp']) for MS (C2-13)オープンhygiene type:refactor
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
メンテナーはふだん 1 日以内に返信