Sorry if this is repetative but still struggling with this.

i wish to multiply 2 long integers together.

if the result is outside of int64 range i want the loop to break
otherwise i want to keep the result and increment the second number.

have tested this, but when the result is out of range it returns a garbage value.
is there any way of making this result 0 for example when this is the case.


I would say it isn't garbage but a wrap around of the variable, what you can do is to take the maximum integer your variable can hold. (should be in std::numeric limits) and divide the maximum integer number by your first int. this is basically saying how many times can i multiply this int and it will fit into the 64bit integer. If the result of that operation is smaller than your second int the multiplication will be out of range.

Hope this helps.