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
2
votes
2 answers

boost::multiprecision random number with fixed seed and variable precision

When using a fixed seed inside a rng, results are not reproducible when precision is varied. Namely, if one changes the template argument cpp_dec_float and runs the following code, different outputs are seen (for each change in…
algae
  • 407
  • 4
  • 15
2
votes
1 answer

Unit tests with boost::multiprecision

Some of my unit tests have started failing since adapting some code to enable multi-precision. Header file: #ifndef SCRATCH_UNITTESTBOOST_INCLUDED #define SCRATCH_UNITTESTBOOST_INCLUDED #include // typedef…
algae
  • 407
  • 4
  • 15
2
votes
1 answer

How to set rounding mode in Boost Multiprecision when using MPFR

I am trying to figure out how I can format mpfr_float numbers using a rounding mode in Boost Multiprecision. In the below example, I expect 1.55 to round to either 1.5 or 1.6 depending on which rounding mode is used, but instead for all cases it…
Jay
  • 23
  • 4
2
votes
2 answers

Type trait for boost multiprecision integers

I want to write a type trait to identify boost multiprecision integer types. I can do this for a concrete type like uint256_t: template struct is_multiprecision_int : std::false_type {}; template <> struct…
Silicomancer
  • 8,604
  • 10
  • 63
  • 130
2
votes
0 answers

boost float128 support for windows 10

I would like to get 128 bit floating precision working for my C++ application on Windows. Currently I am able to do this on both Linux and macOS, using the g++ compilers with the quadmath and boost::multiprecision::float128 libraries. On Windows,…
Juan
  • 3,667
  • 3
  • 28
  • 32
2
votes
1 answer

Why does odeint fail with the newer versions of odeint?

I was struggling with the new version of boost. I am using odeint with mupltiprecision. The following piece of code can be successfully compiled with boost version 1.67.0. However, since version 1.68.0 and newer, I can no longer compile. In version…
Schnarco
  • 183
  • 4
2
votes
1 answer

Find First Set instruction (ffs) for boost multiprecision uint512_t

I'm developing an algorithm that uses __builtin_ffsll() with uint64_t type. I want to switch to 512-bit field using boost multiprecision library (I'm running on a machine with avx512 support). Is there a similar function as the mentioned builtin?…
Purple
  • 711
  • 2
  • 10
  • 19
2
votes
0 answers

how to work around boost::multiprecision::cpp_dec_float division error

Division with boost::multiprecision::cpp_dec_float have some kind of rounding error, as follows: #include #include using my_t =…
Gabriel
  • 2,841
  • 4
  • 33
  • 43
2
votes
1 answer

What is the highest limit for boost-multiprecision cpp_int?

I'm working on factoring large semi-prime numbers. I am working on Java but I am just curious to explore other options as well. I know C++ Boost multiprecision supports large numbers. I found the following information from Boost page: typedef…
User_67128
  • 1,230
  • 8
  • 21
2
votes
1 answer

Mysterious stackoverflow exception in boost::multiprecision::gmp_float::operator=?

I am trying to calculate pi for one of my university project using Ramanujan's formula for arbitrary number of digits after the floating point. For the job, I am using boost::multiprecision library that is simply wrapper around mpfr and mpir I…
kuskmen
  • 3,648
  • 4
  • 27
  • 54
2
votes
1 answer

Is it possible to set a deterministic seed for boost::random::uniform_int_distribution<>?

I'm using boost::random::uniform_int_distribution to generate some unit tests. Notice that I'm using multiprecision, which is why I need to use boost and not the standard library. For my periodic tests, I need to…
The Quantum Physicist
  • 24,987
  • 19
  • 103
  • 189
2
votes
1 answer

Building a large boost unordered_map with cpp_int

I am writing some code in c++ for a class assignment that requires work with multiprecision library such as boost. Basically, I need to build a hash table with some large integers and then lookup a certain value in that table. When I use h, g, p…
Daniel S
  • 53
  • 1
  • 7
2
votes
2 answers

How to take a base 2 logarithm from a boost int256_t?

So I want to take a logarithm from an int256_t. I found this but modifying it to take sizeof int256_t did not work. It will give incorrect results: https://stackoverflow.com/a/11376759 Is there a log function in boost which supports multiprecision?
2
votes
1 answer

boost::multiprecision::number

I'm new in using boost library, so I thanked every one that helps me. #include "gmpxx.h" #include #include #include using namespace std; using…
Mary
  • 55
  • 1
  • 8
1
vote
1 answer

Creating a static lookup table when the integer type is Boost multiprecision number/cpp_int

I'd like to create a static lookup table for powers of ten returned as type boost::mulitprecision's uint256_t: static uint256_t power_ten(const uint8_t n) { static const uint256_t table[] = { 1, 10 // etc }; …
intrigued_66
  • 16,082
  • 51
  • 118
  • 189