1

How to convert a string variable that consists of maximum 100 char to big int ?

My code:

 long long int x; string s="11111111111111111111111111111111"; x=atoll(s.c_str()); cout<<x; 
2
  • What is the maximum value that can be stored in such a "long long int" value? How many characters does the maximum value that can be represented have (in the desired base encoding)? That will be a limiting factor for any standard integer type.. and it's well below "100 char". Commented Jul 16, 2017 at 6:25
  • 1
    Hint: log10(2 ^ 128) is approximately 38 Commented Jul 16, 2017 at 6:36

1 Answer 1

1

You need to use a bignum library, like GNU MP aka GMP or libcrypto.

Since in a 64-bit environment most compiler use 64 bits for a long long int, you can't even reach near 100 decimal digits with a long long.

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.