Sign in Join
Wiki copytemporary

Shl/ru: what changed

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

OldNewLine
11## Обзор
22
33**Sh**ift **l**eft (**shl**) выполняет операцию битового сдвига влево, сдвигая значение на количество бит, указанное в аргументе (противоположное действие [[Shr/ru|shr]]).
44
55Например
66
7-`Команда: 00000100 shl 2 (сдвиг влево на 2 бита)`\
8-` `\
9-`Действие:  00000100 <- 00 (00 добавляется справа к значению; слева 00 "теряется")`\
10-` `\
11-`Результат:  00010000`
7+```text
8+Команда: 00000100 shl 2 (сдвиг влево на 2 бита)
9+
10+Действие: 00000100 <- 00 (00 добавляется справа к значению; слева 00 "теряется")
11+
12+Результат: 00010000
13+```
1214
1315## Сбросить бит
1416
1517``` pascal
1618function ClearBit( const aValue, aBitNumber : integer ) : integer;
1719begin
1820 result := aValue and not( 1 shl aBitNumber );
1921end;
2022```
2123
2224Если вы вызовете ClearBit(%1111,1), то получите %1101 ([[Binary numeral system/ru|двоичное число]] %1111 это 15, а %1101 = 13).
2325
2426Если вызовете ClearBit(13,2), то получите 9 (9 = %1001) .
2527
2628## См. также
2729
2830- [[And/ru|And]]
2931- [[Not/ru|Not]]
3032- [[Or/ru|Установка бита]]
3133- [[Xor/ru|Переключение битов]]
3234- [[Shr/ru|Shr]]
3335- [[Bit manipulation/ru|Bit manipulation]]
3436
3537---
3638*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