Questions tagged [multiprecision]
83 questions
                    
                    14
                    
            votes
                
                2 answers
            
        How many 64-bit multiplications are needed to calculate the low 128-bits of a 64-bit by 128-bit product?
Consider that you want to calculate the low 128-bits of the result of multiplying a 64-bit and 128-bit unsigned number, and that the largest multiplication you have available is the C-like 64-bit multiplication which takes two 64-bit unsigned inputs…
        
        BeeOnRope
        
- 60,350
 - 16
 - 207
 - 386
 
                    9
                    
            votes
                
                6 answers
            
        Storing and printing integer values greater than 2^64
I am trying to write a program for finding Mersenne prime numbers. Using the unsigned long long type I was able to determine the value of the 9th Mersenne prime, which is (2^61)-1. For larger values I would need a data type that could store integer…
        
        user1918672
        
- 91
 - 1
 - 1
 - 2
 
                    6
                    
            votes
                
                2 answers
            
        higher precision floating point using boost lib (higher then 16 digits)
I am running a simulation of physical experiments, so I need really high floating point precision (more than 16 digits). I use Boost.Multiprecision, however I can't get a precision higher than 16 digits, no matter what I tried. I run the simulation…
        
        bnaya
        
- 93
 - 3
 
                    6
                    
            votes
                
                1 answer
            
        How to use sqrt and ceil with Boost::multiprecision?
Do you know how to do this simple line of code without error using Boost::multiprecison ?
boost::multiprecision::cpp_int v, uMax, candidate;
//...
v += 6 * ceil((sqrt(uMax * uMax - candidate) - v) / 6);
Using MSVC there is an error for "sqrt" and…
        
        Aurélien Barbier-Accary
        
- 63
 - 1
 - 4
 
                    6
                    
            votes
                
                1 answer
            
        C++: convert "boost::multiprecision::float128" to "double"
I'm using the boost multiprecision library, and more precisely the boost::multiprecision::float128 type. Using ICPC for compiling, I get some errors when trying to to do something like:
double a = functionA();
where functionA() return a…
        
        user1403546
        
- 1,680
 - 4
 - 22
 - 43
 
                    5
                    
            votes
                
                1 answer
            
        Exact decimal division in MySQL
How to properly divide two DECIMAL values in MySQL and get a result accurate to the number of digits defined in the column type?
Example:
select cast(1/2 as decimal(4,4)),
cast(1 as decimal(4,4))/2,
cast(1 as decimal(4,4))/cast(2 as…
        
        Ferdinand.kraft
        
- 12,579
 - 10
 - 47
 - 69
 
                    5
                    
            votes
                
                1 answer
            
        How to convert from boost::multiprecision::cpp_int to cpp_dec_float<0> (rather than to cpp_dec_float_50, etc.)?
As is made clear in the Boost Multiprecision library documentation, it is straightforward to convert from a boost::multiprecision::cpp_int to a boost::multiprecision::cpp_dec_float:
// Some interconversions between number types are completely…
        
        Dan Nissenbaum
        
- 13,558
 - 21
 - 105
 - 181
 
                    4
                    
            votes
                
                3 answers
            
        Is it possible to store 2 32-bit values in one long int variable?
I want to store two 32-bit values in a single long int variable.
How would you do this on a 32-bit OS using C? Is it possible to store the data in a single long long variable? If so, how is that done?
        
        Syedsma
        
- 1,183
 - 5
 - 17
 - 22
 
                    4
                    
            votes
                
                1 answer
            
        Mathematical operations between two strings
I'm trying to add subtract and multiply numbers with huge decimals C++. 
Example: 
4125487821547.87879845215584844588 - 354556689.899455132265468
What I figured so far is that I need to save inputs as a string, but not sure how to proceed after…
        
        Djon
        
- 41
 - 1
 
                    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
 
                    4
                    
            votes
                
                1 answer
            
        Eigen3 dynamic matrix with boost::multiprecision::mpfr_float
I would like to make matrices and use them using the Eigen3 library, with my number type being Boost.Multiprecision's mpfr_float wrapper.  I can make the matrices just fine, but working with them fails for everything I've tried except matrix…
        
        ofloveandhate
        
- 199
 - 1
 - 10
 
                    4
                    
            votes
                
                2 answers
            
        Print cpp_dec_float in scientific notation without trailing zeros
I'm using cpp_dec_float for arbitrary precision, and it's great, but I'm having trouble figuring out how to print all significant digits.
For example, with this code to setup
using boost::multiprecision::cpp_dec_float;
typedef…
        user1382306
                    4
                    
            votes
                
                2 answers
            
        Multiword addition in C
I have a C program which uses GCC's __uint128_t which is great, but now my needs have grown beyond it.
What are my options for fast arithmetic with 196 or 256 bits?
The only operation I need is addition (and I don't need the carry bit, i.e., I will…
        
        Charles
        
- 11,269
 - 13
 - 67
 - 105
 
                    3
                    
            votes
                
                1 answer
            
        multiprecision unsigned subtraction in C
I am trying to implement multi-precision unsigned subtraction over a finite field (p=2^191-19) in C, but I cannot figure out how to deal with borrow bit!
My operands are represented in radix-2^16 as:
typedef unsigned long long T[12];
which means…
        
        A23149577
        
- 2,045
 - 2
 - 40
 - 74
 
                    3
                    
            votes
                
                2 answers
            
        Multiplication with very large operands
I am implementing a multi-precision module, and at this moment I am stuck in the multiplication.
To do my algorithm I need to multiply two unsigned operands of 64 bits, using a Haswell microarchitecture, and store the result in a memory block.
I'm…
        
        Hélder Gonçalves
        
- 731
 - 6
 - 19