boostorg / boostorg/multiprecision

Wrong division result with cpp_dec_float

Open
#368 24 comments 0 reactions 1 assignee Claimed by @ckormanyos View on GitHub
enhancement low priority
Dominant language
C++
Stars
265
Forks
128
Avg merge
4h 48m
Merged PRs (30d)
2

Description

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.

```cpp
#include
#include

using decimal = boost::multiprecision::number,
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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.