Questions tagged [boost-multiprecision]

Boost library for numeric types with arbitrary precision.

The Boost Multiprecision library is a C++ template library that allows the use of numeric types with a greater precision than built-in types. It has templates for integer and floating-point types, and can work with other libraries like and .

Documentation is available on the Boost website.

90 questions
8
votes
1 answer

C2143/C2518 when trying to compile project using boost.multiprecision

I've been having problems trying to get boost.multiprecision to work in my VC2017 project, and I tried to make the simplest project possible as a proof of concept: #include int main() { …
Xirema
  • 19,889
  • 4
  • 32
  • 68
6
votes
1 answer

Why does Boost::multiprecision::sqrt(1) return 0?

Boost::multiprecision::sqrt(1) seems to return 0 #include #include #include using std::cout; using std::endl; int main() { namespace mp = boost::multiprecision; …
ivme
  • 548
  • 5
  • 14
5
votes
2 answers

Maximal value of the Boost Multiprecision type 'float128' gives me a compilation error with GCC in C++20 mode

This simple code can't be compiled with the -std=c++20 option: #include #include namespace bm = boost::multiprecision; int main() { auto const m = std::numeric_limits::max(); } The…
HEKTO
  • 3,876
  • 2
  • 24
  • 45
4
votes
1 answer

boost::multiprecision::uint128_t sizeof is 24

Basic math (128 / 8 = 16) speaks differently. I'm kinda disappointed and want some answers - since from what I've been used to, that notation(type_num_of_bytes_t) describes not just the amount of data you can put into the variable, but also…
Leontyev Georgiy
  • 1,295
  • 11
  • 24
4
votes
1 answer

how to change at runtime number precision with boost::multiprecision

I've read from the boost::multiprecision documentation: Depending upon the number type, precision may be arbitrarily large (limited only by available memory), fixed at compile time (for example 50 or 100 decimal digits), or a variable controlled at…
Jepessen
  • 11,744
  • 14
  • 82
  • 149
3
votes
1 answer

C++ Boost multiprecision integer uint256_t has sizeof bigger than 32 bytes

It is well known that built-in C++ types uint32_t, int32_t, uint64_t, int64_t and even GCC/CLang built-in types __int128 and unsigned __int128, all have sizeof exactly equal to bit-width divided by 8. But if you print sizeof of Boost's…
Arty
  • 14,883
  • 6
  • 36
  • 69
3
votes
1 answer

boost::multiprecision::cpp_int acting like unsigned long long

So I have a programming assignment in which I have to work with 64 digit numbers. I am currently using the boost::multiprecision::cpp_int library but I'm not able to use it on large numbers. For example- #include…
3
votes
2 answers

Simple alternatives to floating-point when performing arithmetic on short string-encoded rationals

I am creating unit tests for a function that rounds "rational" numbers stored as strings. The current rounding implementation casts the strings to a floating point type: #include #include #include…
3
votes
2 answers

C++ boost/multiprecision: fatal error: mpfr.h: No such file or directory

I have followed this answer and used Boost.Multiprecision to use high accuracy floating point numbers (examples). main.cpp #include #include // Defines the Backend type that wraps MPFR int main(int argc,…
ar2015
  • 5,558
  • 8
  • 53
  • 110
3
votes
0 answers

boost::multiprecision::export_bits throws on a negative cpp_int number

When calling export_bits on a negative boost::multiprecision number based on cpp_int, an exception is thrown from the internal method msb ("testing individual bits in negative values is not supported"). (Boost…
ta55e
  • 194
  • 8
2
votes
1 answer

Checking if a sum of fractions is greater or equal to 1 without calculating the sum

We use boost::multiprecision::cpp_rational to represent fractions. At some point, I have to determine if a sum of a potentially huge number of fractions reaches 1 or not. I don’t care about the exact value of the sum; not even if it’s exactly 1 or…
Quirin F. Schroll
  • 1,302
  • 1
  • 11
  • 25
2
votes
1 answer

Boost::multiprecision and cardinal_cubic_b_spline

I'm new using the boost::multiprecision library and tried to use it combination with boost::math::interpolators::cardinal_cubic_b_spline however I can't compile the program. The example code is #include…
orion
  • 23
  • 3
2
votes
0 answers

Incorrect result with cpp_dec_float division

I'm having a problem with boost cpp_dec_float division producing wrong results. #include #include int main() { using namespace boost::multiprecision; using namespace std; …
Marcin Zukowski
  • 4,281
  • 1
  • 19
  • 28
2
votes
1 answer

Why boost::multiprecision::exp gets stuck when evaluating complex-valued integral?

I am new to Boost C++ Libraries, and naturally I have encountered many problems when using them (due to lack of knowledge and examples available :) One of these problems comes from the following piece of code #include #include…
CuriousQ
  • 31
  • 5
2
votes
0 answers

Keep fundamental type behavior with fixed size boost multiprecision integers

From the cpp_int documentation : The type uses a sign-magnitude representation internally, so type int128_t has 128-bits of precision plus an extra sign bit. In this respect the behaviour of these types differs from fundamental (built-in) 2's…
op325
  • 139
  • 1
  • 12
1
2 3 4 5 6