1

Is there a way in C++ to increase the limit on integers? I want to work with a 13 digit number e.g. 4823423658586. The complier does not allow this.

BeginnerLK
  • 33
  • 1
  • 7
  • 1
    Have you tried using `long long`? What does the compiler not allow? – Beta Carotin Apr 25 '15 at 11:55
  • 1
    Reag e.g. [this reference of the basic types available in C++](http://en.cppreference.com/w/cpp/language/types). – Some programmer dude Apr 25 '15 at 11:56
  • 1
    You can inspect what's the biggest number you can represent with a standard type like [`std::numeric_limits::max()`](http://en.cppreference.com/w/cpp/types/numeric_limits) – πάντα ῥεῖ Apr 25 '15 at 11:57
  • Thats the limit of 64 bits. You can write your own library or look at this duplicate entry [Is there a library or other way to do 128-bit math operations?](http://stackoverflow.com/questions/2604271/is-there-a-library-or-other-way-to-do-128-bit-math-operations) – Rohit Gupta Apr 25 '15 at 12:03

1 Answers1

3

Since the largest 13 digit integer can be stored using 6 bytes you need a type which will store at least 6 bytes, that type is a long long which can hold 8 bytes.

So instead of

int x=100;

use

long long x=100;