So i have a problem where large numbers wont print out correctly. I tried debugging and the number is said to be 657901841 it is gotten from adding all numbers together in a for loop. However when i tried to output the result it would output as -2147483648. I will only post part of the code where it is having the problem because its too long.
1 2 3 4 5 6 7 8 9 10
for (int i = 0; i < 8; i++) { //Adds total together
TimeTotal += NTimeTotal[i];
StepTotal += NStepTotal[i];
}
cout << StepTotal << endl;
So when i tried to print out the number it would give it as a negative stated above. It is really weird because when i played around it a few days ago, it didnt have this problem at all. I dont even remember changing the code around. But now, its surprisingly giving me this error. Any fix for this? I have tried using fixed , setprecision etcc.. No luck ;(. Thanks for any help!