bitshift c
i = 14; // Bit pattern 00001110
j = i >> 1; // here we have the bit pattern shifted by 1 thus we get 00000111 = 7 which is 14/2
bitshift c
i = 14; // Bit pattern 00001110
j = i >> 1; // here we have the bit pattern shifted by 1 thus we get 00000111 = 7 which is 14/2
bitshift c
int i = 7; // Decimal 7 is Binary (2^2) + (2^1) + (2^0) = 0000 0111
int j = 3; // Decimal 3 is Binary (2^1) + (2^0) = 0000 0011
k = (i << j); // Left shift operation multiplies the value by 2 to the power of j in decimal
// Equivalent to adding j zeros to the binary representation of i
// 56 = 7 * 2^3
// 0011 1000 = 0000 0111 << 0000 0011
c right bit shift
// 5: 0...0101
int a = 5;
//shift int a 2 bits
int n = (a >> 2);
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us