I have a code which gives output larger than 32 bits, so I need a big integer class which can do addition and multiplication with bi integers. Anybody knows how to write BigInteger class to implement my code? So I can see the bigger integer outputs.
This is a discussion on how to implement a big int class in c++? within the C++ Programming forums, part of the General Programming Boards category; I have a code which gives output larger than 32 bits, so I need a big integer class which can ...
I have a code which gives output larger than 32 bits, so I need a big integer class which can do addition and multiplication with bi integers. Anybody knows how to write BigInteger class to implement my code? So I can see the bigger integer outputs.
You could consider the C++ wrapper for the GNU MP library.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
I do not want to include a library, I want to implement the big integer class to my code
Ah. What ideas do you have in mind right now?Originally Posted by makonikor
(You could "cheat" by taking at look at how GMP does it, of course. iMalc also has a bignum library implementation among his useful classes that might (or might not) be easier to understand than GMP's implementation.)
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
> I want to implement the big integer class to my code
So do you actually know how to do addition, subtraction, multiplication and division on paper?
I mean, given
do you know what to do without pressing buttons on a calculator?Code:12345678901234567890 + 987654321987654321
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I support http://www.ukip.org/ as the first necessary step to a free Europe.