Binary Shifts (SLL, SLA, SRL, SRA)

preview_player
Показать описание
In this video I go over both logical and arithmetic binary shifting for shift left and shift right.
Рекомендации по теме
Комментарии
Автор

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.

aberroa