This is dangerously misleading. SLA does exactly the same as SLL, because in both cases leftmost (most significant) bits are discarded, and zeroes are inserted on the right side. And also you've mentioned logical and arithmetic and DID NOT mentioned the main and most important difference between them - sign preservation. SRA and SRL, unlike SLA and SLL, differs, and the difference is that in case of arithmetic shift the most significant bit is copied and inserted from the left side. Logical shift just inserts zeroes. This is important because when you do SRL on signed negative value, you get the correct result of division both for positive and negative values. In case of SRL, you only get correct result for positive (or unsigned) values, negatives becomes positive and their value doesn't make much sense from division perspective.
@razzak2007
3 ай бұрын
thanks for you comment, i was lost because of that
@razzak2007
3 ай бұрын
"This is important because when you do SRL" SRA here ?
@aberroa1955
3 ай бұрын
@@razzak2007 Correct, my bad.
@cewithcolin
Ай бұрын
Hi, you are correct. For whatever reason I did not catch this when I made this two years ago. I will upload a correction whenever I get a chance.
Пікірлер: 7