Wrong division result with cpp_dec_float

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

@ckormanyos がすでに取り組んでいます。

2021年9月19日 から。

評価

この issue はまだ評価されていません。

説明

enhancement low priority

I'm using cpp_dec_float to don't deal on rounding issues when mathematic operations give some results with an exact base-10 representation. The result of 69000 / 184 = 375. With cpp_dec_float, it is a bit more.

#include <iostream>
#include <boost/multiprecision/cpp_dec_float.hpp>

using decimal = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<10>,
                                              boost::multiprecision::et_off>;

int main (int argc, char* argv[])
{
  decimal a = decimal {"69000"} / decimal {"184"};
  decimal b = ceil (a);

  std::cout << "a = " << a << std::endl;
  std::cout << "b = " << b << std::endl;

  return 0;
}

The above program shows:

a = 375
b = 376

主要言語
C++
スター
268
フォーク
130
平均マージ
1日 15時間
マージ済み PR(30日)
2

環境構築

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

はじめの一歩

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

boostorg/multiprecision のほかの issue

boostorg/multiprecision の issue をすべて見る

似ている issue

C++ の issue をもっと見る

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

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