# Tip: avoid integer overflow in C++ sums

**URL:** <https://discuss.codechef.com/t/tip-avoid-integer-overflow-in-c-sums/126089>\
**Category:** general\
**Created:** [October 27, 2026, 1:27pm UTC](https://discuss.codechef.com/t/tip-avoid-integer-overflow-in-c-sums/126089 "2026-10-27T13:27:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![relax\_tune\_20](https://discuss.codechef.com/user_avatar/discuss.codechef.com/relax_tune_20/32/359366_2.png) [@relax\_tune\_20](https://discuss.codechef.com/u/relax_tune_20)\
**Post date:** [October 27, 2026, 1:27pm UTC](https://discuss.codechef.com/t/tip-avoid-integer-overflow-in-c-sums/126089/1 "2026-10-27T13:27:26Z")

</div>

A common beginner mistake is multiplying or summing large values in a 32-bit int. If the result can pass about 2 billion, use long long instead. Also use 1LL when multiplying, for example 1LL \* a \* b, so the multiplication happens in 64 bits. What other beginner pitfalls have you run into?
