Yes, what you say is true. When you cast a byte to an int, you will get a value in the range of -128 to 127. (If you don't understand why this happens or why this might be a sensible thing to do, wait until you take the 15-213 course. Otherwise, just take my word for it.)
The best thing to do, then, is to add 128 to the result of the cast. This will give you a value in the range of 0 to 255. |