<!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 - Lsr
</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="lsl+en">Previous</a>&nbsp;
<a href="ltrim+en">Next</a>&nbsp;
</td></tr></table>
<div class="notab">
<h1>
Lsr
</h1>
<div class="black"><font size="-2"><b>Syntax</b></font></div>
<pre class="syntax"><u>Value</u> <b>= Lsr (</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. 0 bits are shifted from the left into the sign bit.
<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 Lsr(11, 3)
<hr>1</pre>
<p>

<p>
<div class="gray"><font size="-2"><b>Example</b></font></div>
<pre class="example">PRINT Lsr(-11, 3)
<hr>536870910</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">
Lsr with a negative <a href="type/short+en">Short</a> <u>Number</u> argument will have as result a <a href="type/short+en">Short</a> which has 32 bits,
bits 16 to 31 are the result of shifted pattern &HFFFF0000&
<p>
This is a Bug of Verion 1.9.28
<div class="gray"><font size="-2"><b>Example</b></font></div>
<pre class="example">PRINT Lsr(CShort(&HCa83), 4)
<hr>268434600</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>

