|
-
Dec 20th, 2011, 12:55 PM
#1
[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?
Last edited by LaVolpe; Dec 20th, 2011 at 01:43 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|