1

Which C++ type is large enough to represent a 64 digit decimal number like

3141592653589793238462643383279502884197169399375105820974944592 ?

4
  • @KobyDouek 64 digits, not bits. Commented Mar 13, 2017 at 11:51
  • Probably none. long long is required to be at least 64 bits, but could theoretically be longer. You have to check your compiler's manual. Commented Mar 13, 2017 at 11:51
  • Search and research arbitrary or multiple precision number libraries. Commented Mar 13, 2017 at 11:52
  • The misfortunes of not being able to de-flag Commented Mar 13, 2017 at 11:54

1 Answer 1

5

There's nothing "out of the box" for this: you'd need a 64 * log(10) / log(2) bit integral type. (A std::int256_t from the future would suffice!)

If you're not going to manipulate the number mathematically in any way, then use a std::string.

Otherwise, consider using the large number library in Boost: www.boost.org. That stuff has a habit of making it into future C++ standards. Note that

#include <boost/multiprecision/cpp_int.hpp> using namespace boost::multiprecision; 

yields the int256_t type.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.