<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../style.css">
<title>
Gambas Documentation - Shr
</title>
</head>
<table class="none" width="100%" cellpadding="0" cellspacing="0" border="0">
<tr><td align="left">
<font size="-1">
<a href="../../help+en"><img class="flag" alt="Home" border="0" src="../../img/lang/en.png" align="center"></a>&nbsp;
<a href="../lang+en">Up</a>&nbsp;
<a href="shl+en">Previous</a>&nbsp;
<a href="sin+en">Next</a>&nbsp;
</td></tr></table>
<div class="notab">
<h1>
Shr
</h1>
<div class="black"><font size="-2"><b>Syntax</b></font></div>
<pre class="syntax"><u>Value</u> <b>= Shr (</b> <u>Number</u> <b>,</b> <u>Bit</u> AS Integer <b>)</b></pre><p>

Returns <u>Number</u> shifted to the right by <u>Bit</u> bits.
The sign of <u>Number</u> is kept. (Except if <u>Number</u> is a <a href="type/byte+en">Byte</a>)
<p>
The type of <u>Number</u> may be <a href="type/byte+en">Byte</a>, <a href="type/short+en">Short</a>, <a href="type/integer+en">Integer</a>, or <a href="type/long+en">Long</a>
<p>
The valid range of <u>Bit</u> depends on the type of the <u>Number</u> argument:
<p>
<table class="table" border="0" bordercolor="#000000" cellpadding="4" cellspacing="0">
<tr><th>
Type
</th><th>
Range of <u>Bit</u>
</th></tr>
<tr class="dark"><td valign="top">
<a href="type/byte+en">Byte</a>
</td><td valign="top">
0...15
</td></tr>
<tr><td valign="top">
<a href="type/short+en">Short</a>
</td><td valign="top">
0...15
</td></tr>
<tr class="dark"><td valign="top">
<a href="type/integer+en">Integer</a>
</td><td valign="top">
0...31
</td></tr>
<tr><td valign="top">
<a href="type/long+en">Long</a>
</td><td valign="top">
0...63
</td></tr>
</table>
<p>
<div class="gray"><font size="-2"><b>Example</b></font></div>
<pre class="example">PRINT Shr(11, 3)
<hr>1</pre>
<p>
<div class="gray"><font size="-2"><b>Example</b></font></div>
<pre class="example">PRINT Shr(-11, 3)
<hr>-2</pre>
<p>

<div class="warning"><table class="none" border="0"><tr><td width="40" valign="top"><img border="0" src="../../img/warning.png" align="center"></td><td valign="top">
<a href="asr+en">Asr</a> with a negative <a href="type/byte+en">Byte</a> <u>Number</u> argument will not keep
the sign because the datatype <a href="type/byte+en">Byte</a> is always unsigned.
<p>
<div class="gray"><font size="-2"><b>Example</b></font></div>
<pre class="example">PRINT Asr(CByte(-64), 2)
<hr>48</pre>
</td></tr></table></div>
<p>
<hr><b>See also</b><br>
<a href="../cat/bit+en">Bits Manipulation Functions</a>&nbsp; <a href="../cat/logicop+en">Logical Operators</a>&nbsp;

</div>
</body>
</html>

