Questions tagged [multiprecision]

83 questions
3
votes
1 answer

What is the precision of cpp_dec_float_50?

Looking at the name and the Boost Multiprecision documentation I would expect that the cpp_dec_float_50 datatype has a precision of 50 decimal digits: Using typedef cpp_dec_float_50 hides the complexity of multiprecision to allow us to define…
maxschlepzig
  • 35,645
  • 14
  • 145
  • 182
3
votes
3 answers

Digit-count of a boost::multiprecision::cpp_int

What is an efficient way get the digit count of a boost::multiprecision::cpp_int? The log10() function is apparently not compatible with multiprecision integers and I can't figure out any other way to do this.
user1892304
  • 617
  • 1
  • 6
  • 11
3
votes
2 answers

Force cpp_dec_float to round down

I am using .str(n, std::ios_base::scientific) to print ccp_dec_floats. I've noticed that it rounds up. I am using cpp_dec_float for accounting, so I need to round downward. How can this be done?
user1382306
3
votes
2 answers

Multiprecision library zkcm and sizeof()

I am using the multiprecision complex number library (zkcm) and want to compare some results using complex. At one point I try to double check the memory of the variables using sizeof() but I get the same answer (32) no matter how big a…
jorgen
  • 3,425
  • 4
  • 31
  • 53
2
votes
1 answer

boost multiprecision cpp_int output/to string very slow

Playing around with the boost multiprecision library. Calculating some big factorial numbers and such. Problem is the output takes too long. 100,000! takes 0.5 seconds to calculate and 11 seconds to print. 1,000,000! takes half an hour (yes the…
Richard
  • 43
  • 4
2
votes
1 answer

Trying to convert large integers to binary using as.binary

I have large integers that I need to convert to binary, but I keep getting this warning message: Warning messages: In h(num) : probable complete loss of accuracy in modulus 2: In diff(x%%2^(num_digits:0)) : probable complete loss of accuracy…
2
votes
1 answer

Outputting values from CAMPARY

I'm trying to use the CAMPARY library (CudA Multiple Precision ARithmetic librarY). I've downloaded the code and included it in my project. Since it supports both cpu and gpu, I'm starting with cpu to understand how it works and make sure it does…
David Wohlferd
  • 7,110
  • 2
  • 29
  • 56
2
votes
2 answers

Issue with function that adds large integers stored in vectors

So I' ve decided to write my own multiprecision data type. I've written a simple function that adds large numbers stored in vector. vector Add(vector x, vector y){ unsigned int x_size =…
A. Szokalski
  • 65
  • 1
  • 6
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

Subnormal numbers in different precisions with MPFR

I would like to emulate various n-bit binary floating-point formats, each with a specified e_max and e_min, with p bits of precision. I would like these formats to emulate subnormal numbers, faithful to the IEEE-754 standard. Naturally, my search…
James Paul Turner
  • 791
  • 3
  • 8
  • 23
2
votes
0 answers

Multiple Precision Complex Number in R

Complex Number in R is defined as: function (length.out = 0L, real = numeric(), imaginary = numeric(), modulus = 1, argument = 0) I've a program which aims to process multiple precision values in the real case and complex case. R does not support…
complextea
  • 393
  • 1
  • 5
  • 16
2
votes
1 answer

boost mpz_int with base other than 2, 8, 10, 16

I can create multi precision integers from a string with standard base #include ... using namespace boost::multiprecision; mpz_int decimal("10"); mpz_int hexadecimal("0xa"); mpz_int octal("012"); mpz_int…
jlaurens
  • 59
  • 3
2
votes
2 answers

Using boost multiprecision with trigonometric function

Consider the following code which creates a multiprecision floating-point number 'a' by using boost. How do I use boost library to invoke trigonometric functions? For example, I hope to calculate sin(a). #include #include…
Wei-Fan Chiang
  • 273
  • 1
  • 7
2
votes
1 answer

Writing boost::multiprecision data type to binary file

I was using the boost::multiprecision::uint128_t type in order to perform bitwise operations on a 128 bit value. However I am having trouble writing the 128 bit value out to a binary file. Specifically with the need to pad out the value with…
Tim
  • 21
  • 3
2
votes
2 answers

Problems using boost multiprecision library

I am trying to write a base conversion program that will work for numbers beyond the limits of C++'s long long integers. I am trying to use boost multiprecision libraries but have not made it very far. I have tried to compile the following: #include…
Jonathan Basile
  • 649
  • 1
  • 10
  • 20