Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle big numbers?

Tags:

c++

boost

I have a very large number, assume some transaction id or big money involved. So, how I will handle the calculation on these ( add, multiple etc). Does any other was to store it in the generic storage type( long, long long etc) to take care of such situation? Does boost support the solution?

like image 906
CrazyC Avatar asked Dec 07 '25 03:12

CrazyC


1 Answers

You use a library that handles big numbers, like The GNU Multiple Precision Arithmetic Library which seems to be the most common. Or if you want Boost specifically, there's always the Multiprecision library (which can use GMP as backend).

like image 156
Some programmer dude Avatar answered Dec 09 '25 20:12

Some programmer dude