Home > Back-end >  Why didn't abandon bitwise shift to the left, high
Why didn't abandon bitwise shift to the left, high

Time:10-01

Bitwise left for 2, 217 or 11011001 left two, abandon "11" high low completion "00", you can get 01100100, or 100, but I calculated is 868, 1101100100, at that moment, low fill the "00", but not high the "11" give up!!!!!!

CodePudding user response:

post code

CodePudding user response:

Since 217, high, 1 means the negative, c + + for negative shift, is undefined behavior,
For negative a, a, & lt;
For unsigned and signed a nonnegative. A, b & gt;> The value of b is a/2 b
The integer part,

For negative a, a. & gt;> The value of b is implementation-defined (most arithmetic moves to the right on the platform, so the results keep negative),

CodePudding user response:

The second point
LhsFor the built-in operators, LHS and RHS must have an enum type to integer or no scope, for two operand integer promotion,
After the return type is the type of the left operand,

CodePudding user response:

The question, the programming results for 868, but I was 100

CodePudding user response:

The inside of the Java

CodePudding user response:

Java please turn out the Java area, here is the c/c + + plate

CodePudding user response:


Java for & lt; CodePudding user response:

Logical shift to the left and the count left, an abandoned the sign bit, a don't abandon the sign bit,
This is only a knowledge, there is no analysis of specific problems of the building Lord,

CodePudding user response:

My understanding is that 217 of the space is 2 bytes or 4 bytes, according to the operating system, if be 2 bytes, binary is 0000 217 0000 1101 1001, left is 0000 0011 0110 0100, becomes 868