Shl/ru
Deutsch · English · Français · Suomi · Русский
Обзор
Shift left (shl) выполняет операцию битового сдвига влево, сдвигая значение на количество бит, указанное в аргументе (противоположное действие shr).
Например
Команда: 00000100 shl 2 (сдвиг влево на 2 бита)
Действие: 00000100 <- 00 (00 добавляется справа к значению; слева 00 "теряется")
Результат: 00010000Сбросить бит
function ClearBit( const aValue, aBitNumber : integer ) : integer;
begin
result := aValue and not( 1 shl aBitNumber );
end;Если вы вызовете ClearBit(%1111,1), то получите %1101 (двоичное число %1111 это 15, а %1101 = 13).
Если вызовете ClearBit(13,2), то получите 9 (9 = %1001) .
См. также
From the Free Pascal wiki, page "Shl/ru", as it stood on 2020-02-26 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.