804 views
1 votes
1 votes

pls someone explain

How to left shift this number ?

1010110<<2

Answer 1: shifting to the left means adding extra 0's as rightmost bits so in this case it means 101011000 now digit will be 1011000 

but 1010110 represents 86 in decimal and left shift by 2 means multiply with 4 to the decimal number and now result 344 =101011000 now m confused ?

1 Answer

Best answer
1 votes
1 votes

Left shift means : The number to the left of the operator is shifted the number of places specified by the number to the right.

like 1010110<<2 

it would be after left shift 101011000

In general shifting N places left is the same as multiplying by 2 to the power N (written as 2N)

A left shift 1 place is the same as multiplying by 2

A left shift 2 place is the same as multiplying by 4

see this example , number is 00100101

shift left 2 places

input 0 0 1 0 0 1 0 1
result 1 0 0 1 0 1 0 0
selected by

Related questions

0 votes
0 votes
0 answers
2
Overflow04 asked Sep 3, 2022
314 views
Does the formula(2^(k-1)) used for caculating the biasing value is correct?