Page 1 of 1

Byte overflow

Posted: Mon Sep 16, 2013 9:35 am
by Jan Lichtenbelt
I had accidentally made the following error. ABC is a byte and in the program one step is ABC=500.
What will happen? Can this give a wrong result in an other variable?

Kind regards

Jan Lichtenbelt

Re: Byte overflow

Posted: Mon Sep 16, 2013 10:56 am
by JonnyW
Hi Jan.

Arrays can overflow and cause corruption, but writing too large a value to a variable will not, and wrap like this on a byte can even be a way of helping optimise code.

Here 500 = 0x1F4 so when this is clipped to a byte it should equal 0xF4, or 244.

Jonny