Does STL have a BigInt class implementation? (numbers with many digits held into a container)
Asked
Active
Viewed 9,569 times
3 Answers
16
The C++ standard library (sometimes erroneously referred to as "STL") does not contain any extended precision support.

Mark Ransom
- 299,747
- 42
- 398
- 622
-
1Why is Standard Template Library erroneously called STL? – XCS Feb 15 '11 at 15:34
-
@Cristy, STL is the name of a specific template library implementation that predates the C++ standardization, which is mostly but not completely compatible. I might have been a little harsh, I remember now Scott Meyers' book is called "Effective STL" - if such an authority still uses the term, it should be OK for the rest of us. – Mark Ransom Feb 15 '11 at 17:30
-
The STL is just a small part of the C++ standard library. – Chris Dodd May 29 '11 at 18:42
-
3The Standard Template Library *is* the STL, but STL does not refer to the C++ standard library. The Standard Template Library is just a small part of the C++ standard library as Chris Dodd said. The C++ standard library contains the STL and more. I hope this clears up any confusion. – Phoenix Mar 27 '13 at 12:10
-
@Phoenix, the truth is more nuanced than that - see http://stackoverflow.com/questions/5205491/whats-this-stl-vs-c-standard-library-fight-all-about – Mark Ransom Mar 27 '13 at 15:31
-
@MarkRansom in light of that comment perhaps you could remove the word "erroneously" from your answer... – M.M Aug 07 '15 at 01:24
-
@MattMcNabb I still think it's an error, just one that's easily forgiven. As humans we appreciate having simple names for things. Ask Xerox and Kleenex how they feel about that subject. – Mark Ransom Aug 07 '15 at 04:21
5
Unfortunately, the C++ standard library does not natively support arbitrarily long integers. However, these libraries can help you getting the job done:
- The GNU Multiple Precision Arithmetic Library (has both C and C++ interfaces, also refered as GMP)
- InfInt
- C++ BigInt class
- Boost.Multiprecision
- Multiple Precision Integers and Rationals (written in assembly, has a C interface)
- BigDigits multiple-precision arithmetic (in C)
- BigIntegerCPP (only supports addition and multiplication)
- C++ Big Integer Library (no longer maintained)

Mathieu Rodic
- 6,637
- 2
- 43
- 49
-
1Such a comprehensive list should also include boost multiprecision: http://www.boost.org/doc/libs/master/libs/multiprecision/doc/html/index.html – Mr.WorshipMe Mar 24 '17 at 10:17