Removed dead assignment.
Simplified code.
Fixed some whitespace issues.
Simplified condition.
Fixed type.
Simplified condition.
Removed strange check.

The comment does not help me to understand the problem at all.
Provide debug information.
Use local variables for bit sizes.
Merge if statements.
Merge if statements.