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
1
vote
1 answer

Interoperability between C++ Boost Multiprecision and Python's mpmath

I have experience working with both Boost Multiprecision and with Python's mpmath, separately. When it gets to making both communicate (for example to create Python extensions in C++), my attempts have always involved some sort of wasteful…
AndraSol
  • 65
  • 6
1
vote
1 answer

boost::multiprecision::uint128_t sizeof is 16

Per this link, boost::multiprecision::uint128_t sizeof is 24 uint128_t should be 24. I tried it on Linux Ubuntu 16.04 x64, and it says 16. Any reason?
user2584960
  • 645
  • 1
  • 6
  • 20
1
vote
1 answer

How do you find the Modular Inverse of two very big numbers using any of the Boost Multiprecision Library types? (cpp_int, gmp_int etc)

I need to find the Modular Multiplicative Inverse of two numbers, who data types are any of the ones offered by Boost's Multiprecision library (gmp_int, cpp_int etc). Is there a built in function to do so? If not, can you explain how to proceed?
1
vote
2 answers

Unable to compile example boost::multiprecision with intel compiler on windows

I am using VS 2017 Community edition, Intel Compiler 17.00 update 6 and and boost 1.66, trying to learn my way around boost::multiprecision::float128. Literally taking the example code from here and putting it in a new project for VS. Compiling…
Starlin
  • 21
  • 4
1
vote
1 answer

Boost multiprecision cpp_int multiplied by a float

It is possible to multiply a boost multiprecision int by a floating point number? Is this is not supported? using bigint = boost::multiprecision::number>; boost::multiprecision::bigint x(12345678); auto…
Juan Leni
  • 6,982
  • 5
  • 55
  • 87
1
vote
1 answer

Boost Interval with Multiprecision

I try to use the boost interval arithmetic library together with the boost multiprecision library. If I use standard double precision with the native double datatype, everything works fine. With the multiprecision library however, it produces…
1
vote
1 answer

C++ BigInteger to byte array

In Java, there is a BigInteger class to using large numbers, and it has a converter function: toByteInteger like this: private static final BigInteger N = new BigInteger(HEX_N, 16); ... byte[] digest = messageDigest.digest(N.toByteArray()); In C++,…
gkhanacer
  • 575
  • 7
  • 25
1
vote
1 answer

boost multiprecision gmp_float convert_to() gives compilation error

I am using boost multiprecision library floating point number. I need to map a gmp_float to an tanh and then take it as a double because value of tanh will be [0, 1). When I use convert_to() I get compilation error as shown in the snippet…
Neel Basu
  • 12,638
  • 12
  • 82
  • 146
0
votes
0 answers

Rounding a floating-point number to a given precision

If I give a double value and an integer value, I want to round that double to the precision of the integer value accurately. In the end, I want to get a double value which is more accurate as the output. I tried it using the boost multi-precision…
0
votes
1 answer

CMake, Boost multiprecision float128 and Clang "fatal error: 'quadmath.h' file not found"

I'm using CMake to compile my project with Clang14 on Ubuntu 22.04. I'm not very advanced with CMake, but I get by. I've just added float128 from my Boost version 1.74: #include boost::multiprecision::float128…
rare77
  • 297
  • 6
0
votes
1 answer

'=': cannot convert from 'int' to 'std::_Iosb::_Fmtflags'

Trying to use ios format flags to format the string representation of Boost multiprecision cpp_int. Everything works with gcc standard c++17, but in Visual Studio 2019 (v142) same standard, I'm getting a compilation error when using '|' operator to…
Vlad Keel
  • 372
  • 2
  • 13
0
votes
1 answer

format boost multiprecision cpp_int with fmt

I'm trying to format a boost multiprecision cpp_int using fmt library. Here's the code I tried using boost::multiprecision::cpp_int; int main() { cpp_int v("0x8FFFFFFFFFFFFFFFF"); std::string buffer; …
Vlad Keel
  • 372
  • 2
  • 13
0
votes
0 answers

boost multiprecision does not work c++ builder community 64 bit version

I have c++ builder community version 10.4. Boost multiprecision works fine for Win32 compiles, but does not compile for Win64, giving link errors. c++builder is using version 1.70 of boost. [ilink64 Error] Error: Unresolved external '__udivti3'…
david
  • 1
  • 1
0
votes
0 answers

How was boost cpp_int arithmetic operations were implemented?

I have look at GMPs source code and It seems to me that it uses hand written assembly code to achieve fast peformance in its mpz_*/mpn_* arithmetic implementations, but when I look at boost's source code, I don't see any hand written assembly code…
Bondrewd
  • 1
  • 2
0
votes
1 answer

Convert boost::multiprecision::cpp_dec_float_100 to string with precision

In my code I want to have a function which performs some calculations based on boost::multiprecision::cpp_dec_float_100 and returns string as a result with some precision, but the question is how I should set the precision ? e.g. If the precision is…
bladzio
  • 414
  • 3
  • 15