Sign in Join
Wiki copytemporary

Shl/ru: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: Shl/ru

OldNewLine
1+## Обзор
2+
3+**Sh**ift **l**eft (**shl**) выполняет операцию битового сдвига влево, сдвигая значение на количество бит, указанное в аргументе (противоположное действие [[Shr/ru|shr]]).
4+
5+Например
6+
7+`Команда: 00000100 shl 2 (сдвиг влево на 2 бита)`\
8+` `\
9+`Действие:  00000100 <- 00 (00 добавляется справа к значению; слева 00 "теряется")`\
10+` `\
11+`Результат:  00010000`
12+
13+## Сбросить бит
14+
15+``` pascal
16+function ClearBit( const aValue, aBitNumber : integer ) : integer;
17+begin
18+ result := aValue and not( 1 shl aBitNumber );
19+end;
20+```
21+
22+Если вы вызовете ClearBit(%1111,1), то получите %1101 ([[Binary numeral system/ru|двоичное число]] %1111 это 15, а %1101 = 13).
23+
24+Если вызовете ClearBit(13,2), то получите 9 (9 = %1001) .
25+
26+## См. также
27+
28+- [[And/ru|And]]
29+- [[Not/ru|Not]]
30+- [[Or/ru|Установка бита]]
31+- [[Xor/ru|Переключение битов]]
32+- [[Shr/ru|Shr]]
33+- [[Bit manipulation/ru|Bit manipulation]]
34+
35+---
36+*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](/wiki-contact).*

Back to history