This documentation is out of date.
The new version of the documentation is here: https://cannylogic.com/docs |
Difference between revisions of "Right shift"
[unchecked revision] | [unchecked revision] |
(3 intermediate revisions by 2 users not shown) | |||
Line 6: | Line 6: | ||
!colspan="2" style="background-color:#AFEEEE;"|Appearance | !colspan="2" style="background-color:#AFEEEE;"|Appearance | ||
|- | |- | ||
− | |colspan="2" align="center" style="padding:10px;"|[[ | + | |colspan="2" align="center" style="padding:10px;"|[[File:5_4_6_2.png]] |
|- | |- | ||
!colspan="2" style="background-color:#AFEEEE;"|Symbol | !colspan="2" style="background-color:#AFEEEE;"|Symbol | ||
Line 14: | Line 14: | ||
!colspan="2" style="background-color:#AFEEEE;"|Group | !colspan="2" style="background-color:#AFEEEE;"|Group | ||
|- | |- | ||
− | |colspan="2" align="center"|[[Built-in Function Blocks | Bitwise operators]] | + | |colspan="2" align="center"|[[Built-in Function Blocks#Bitwise operators | Bitwise operators]] |
|- | |- | ||
!colspan="2" style="background-color:#AFEEEE;"|Inputs | !colspan="2" style="background-color:#AFEEEE;"|Inputs | ||
Line 37: | Line 37: | ||
<div style="min-height:100%;display:block;"> | <div style="min-height:100%;display:block;"> | ||
<div style="float:left;width:70px;"> | <div style="float:left;width:70px;"> | ||
− | [[ | + | [[File:5_4_6_1.png|left|Icon]] |
</div> | </div> | ||
Line 73: | Line 73: | ||
|} | |} | ||
− | == | + | == Features == |
The result of logical right shift:: | The result of logical right shift:: | ||
Line 86: | Line 86: | ||
== Examples == | == Examples == | ||
{| | {| | ||
− | |[[ | + | |[[File:5_4_6_3.png|thumb|400px|As decimal]] |
− | |[[ | + | |[[File:5_4_6_4.png|thumb|500px|As binary]] |
|} | |} | ||
Latest revision as of 19:48, 13 December 2016
Appearance | |
---|---|
Symbol | |
>> | |
Group | |
Bitwise operators | |
Inputs | |
Value: | Integer |
Shift, bits: | Integer |
outputs | |
Result: | Integer |
Version CANNY Lab | |
from 0.6b |
Logical shift to the Right. Set the output result as the logical right shift in binary representation of the input "Value", the number of bits to shift specified by the input "Shift, bit".бит».
In other words, the result is equivalent to the result of copying each bit in binary representation of input "value" to its right position, to the number of times specified by the value of the input "Shift, bit". Thus, the most significant (left-most) bit in the binary representation of the results each time gets a "0".
For example:
Value | = | 22 | = | 0x0016 | = | 0b0000000000010110 |
Shift, bits | = | 2 | ||||
Result | = | 5 | = | 0x0005 | = | 0b0000000000000101 |
Features
The result of logical right shift::
for one bit — equivalent to the results of its integer division by 2
for two bits — equivalent to the results of its integer division by 4
for three bits — equivalent to the results of its integer division by 8
etc.