[RESOLVED] Bit Shifting with C
I've come to understand C coding quite a bit over the past week. I am not a C programmer at all. Trying to convert/interpret some C code, I've come across the following simple calculations and am unsure what the results would be. I do not own a C compiler.
If anyone could provide the answers to the these 2 calculations and/or answer my following question, I would very much appreciate it.
All variables are defined as: int
Calc 1: x4 =-17728437 x5 =-3330316
x2 = (181 * (x4 + x5) + 128) >> 8
Calc 2: x4 = 33479030 x5 = 6609623
x2 = (181 * (x4 + x5) + 128) >> 8
Where I'm having problems with this is that calcs above, before shifting, will result in a value that needs more than 32 bits.
Is there some sort of variable type promotion?
or possibly truncation?
When this is the case, what part of the result, exactly, whether positive or negative, is shifted? just 32 bits, 32+ bits, something else? :confused:
Re: [RESOLVED] Bit Shifting with C
Though the thread was educational, my problem was not with bit shifting after all. I misunderstood the precedence of ++ operator when on the left or right side of a pointer. Bottom line, I was using the wrong value for the x4, x5 variables.