I program in assembler, not C, therefore that link does not mean anything to me. However, the C compiler uses the native word size which is usually larger than 8-bits. I still stand by what I said about 255 being a negative number in signed 8-bit words.
What you can do in C, you can do in assembler. And the concept of promoting variables is exactly the same. And promoting variables is exactly in the heart of the original problem.
What is the minimum number of bits that you need to promote your variables to so that overflow is avoided? That is essentially the question.
Perhaps the compiler expands the 8-bit word to a larger size if if the value does not fit into 8-bits. If it does, that goes beyond the problem we are discussing.
If the variables are not allowed to be expanded, then why ask the minimum number of bits needed? That would be just stupid.
Of course the variables are epanded.. that is the whole point of the question. How much you need to expand to avoid overflow?
Last edited: