Questions tagged [boost-multiprecision]

Boost library for numeric types with arbitrary precision.

This library allows to create numeric types with a greater precision than default types like double int and so on.

59 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
  • 18,577
  • 4
  • 26
  • 60
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; …
Chad
  • 548
  • 4
  • 14
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,147
  • 8
  • 23
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
  • 4,338
  • 4
  • 36
  • 83
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
  • 184
  • 8
3
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
  • 9,377
  • 11
  • 64
  • 111
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
  • 211
  • 3
  • 12
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
  • 7,280
  • 6
  • 49
  • 101
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
  • 173
  • 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
  • 663
  • 1
  • 10
  • 18
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,298
  • 4
  • 22
  • 45
2
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…
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
  • 21,050
  • 13
  • 77
  • 143
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
  • 33
  • 7
1
2 3 4