C language shift operators >> ASR Arithmetic shift right and equivalents

An experiment to see if the C language is right in the end

(1) LSR Logical shift right, the sign bit is not copied

(2) ASR Arithmetic shift right, the sign bit and copy reservation.

S32 a=0x81234567; /-2128394905

S32 result1=(a>>16);  //

S16 result2=(a>>16); 

S16 rrsult3 = a / 65536; // 65536 is a power of 162

result

result1 is 0xffff8123

result2 is 0x8123

result3 is 0x8124

C language is visible right arithmetic shift right, retain and replicate the sign bit

Published 11 original articles · won praise 0 · Views 611

Guess you like

Origin blog.csdn.net/wuqi1003/article/details/104083078