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
1 Answer
You don't need to.
>>> sum([
... 1243926478235632786572938657832682396538279658237956832976482375678239659782365,
... 23590237589734985720423803758031640192748372946743079324780137092704730297409327409237409237432,
... ])
23590237589734986964350281993664426765687030779425475863059795330661563273891703087477069019797
Python has arbitrary-size integers, that can become way larger than C's long long.
valueas long as you have enough memory :)inthas no maximum value. Even in Python 2, whereinthad some (platform-specific) maximum, results were promoted to the unboundedlongtype as necessary. There was virtually no semantic difference betweenintandlong; the distinction represented an implementation detail that was swept under the rug in Python 3.