After looking through the code one more time, I noticed that for some reason some odd reason, when adding the uint8 value 156 to the double 0, the result is a uint8 value 156. Then, when trying to add the uint8 value 159 to the sum's value, which is the uint8 value 156, the result can not be any larger than 255 based on the size limitations for the uint8 data type. However, I always thought Matlab's policy during an addition was to take the larger data type to prevent loss. Is that not how Matlab handles types? If so what is the method it uses to decide which data type to keep in situations like this? I program with Matlab a lot for my classes, and I feel like this is something I'll need to know.
My origional question is answered, I can just force the type to remove the issue. But why this is happening is still a mystery for me, hence why I'm not closing the question.