+ 1

Why large calulation in c++ are always wrong?

23rd Feb 2019, 3:50 PM
MAxX
MAxX - avatar
2 Respostas
+ 8
Because of overflow. Every number type, like int, what you're probably using, has maximum upper and lower limits, and if you go beyond them, your results get messed up. Look for example here: https://docs.microsoft.com/en-us/cpp/cpp/integer-limits?view=vs-2017
23rd Feb 2019, 4:04 PM
HonFu
HonFu - avatar
+ 6
try to use long int to avoid this problem
24th Feb 2019, 5:02 AM
Shahil Ahmed
Shahil Ahmed - avatar