+ 2

Will it result right or not?

When we take 2 integer types of variables, it reserved memory of 2 bytes both and then we declare third variable of int type to store the addition of first both and if the sum both is high then 2 bytes then what will happen?

16th Jan 2018, 3:59 AM
ImranKhan CD
ImranKhan CD - avatar
4 Antworten
+ 3
It sounds like you are describing integer overflow. In the event that an integer variable assigned a value that exceeds its range, the new value will switch over to the opposite extreme. For example, the integer range is between -2147483648 and 2147483647. If an integer variable is assigned a value equal to max value + 1, the assigned value will be the min value. Here is some code I just wrote to demonstrate this: https://code.sololearn.com/cocB0xRzq6MW/#cpp Here is a good article explaining this concept further. http://nethack.wikia.com/wiki/Integer_overflow
16th Jan 2018, 4:36 AM
David Carroll
David Carroll - avatar
+ 3
You are most welcome. If you believe that was the answer, you can click the check mark next to the answer to mark it for others to see.
16th Jan 2018, 4:41 AM
David Carroll
David Carroll - avatar
0
thanks
16th Jan 2018, 4:38 AM
ImranKhan CD
ImranKhan CD - avatar
0
thanks
22nd Jan 2018, 12:12 PM
Proto