4

I have a task to calculate a sum of very big integers. the sum could be over the limit of max value of int. I'd like to use long long int type like in c to prevent this. python is dynamic type language. but there must be someway to declare this long long int type. help me to declare long long int type in python. thanks

6
  • 3
    It will take the value as long as you have enough memory :) Commented Apr 9, 2019 at 15:11
  • 1
    stackoverflow.com/questions/1764548/… Search you`r question on stack. Commented Apr 9, 2019 at 15:12
  • 1
    no matter how big they are, I think python will handle it. love python : ) Commented Apr 9, 2019 at 15:14
  • 1
    You don't declare types in Python. That's why it is called a dynamic language. Commented Apr 9, 2019 at 15:15
  • 1
    Python 3 int has no maximum value. Even in Python 2, where int had some (platform-specific) maximum, results were promoted to the unbounded long type as necessary. There was virtually no semantic difference between int and long; the distinction represented an implementation detail that was swept under the rug in Python 3. Commented Apr 9, 2019 at 15:37

1 Answer 1

3

You don't need to.

>>> sum([
...     1243926478235632786572938657832682396538279658237956832976482375678239659782365,
...     23590237589734985720423803758031640192748372946743079324780137092704730297409327409237409237432,
... ])
23590237589734986964350281993664426765687030779425475863059795330661563273891703087477069019797

Python has arbitrary-size integers, that can become way larger than C's long long.

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.