<!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 - Shl
</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="shell+en">Previous</a>&nbsp;
<a href="shr+en">Next</a>&nbsp;
</td></tr></table>
<div class="notab">
<h1>
Shl
</h1>
<div class="black"><font size="-2"><b>Syntax</b></font></div>
<pre class="syntax"><u>Value</u> <b>= Shl (</b> <u>Number</u> <b>,</b> <u>Bit</u> AS Integer <b>)</b></pre><p>

Returns <u>Number</u> shifted to the left by <u>Bit</u> bits.
<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...7
</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 Shl(11, 3)
<hr>88</pre>
<p>
It may be useful to expand the type of an argument.
Use for this <a href="clong+en">CLong</a>, <a href="cint+en">CInt</a>, <a href="cshort+en">CShort</a>
<p>
<div class="gray"><font size="-2"><b>Example</b></font></div>
<pre class="example">DIM b1 AS Byte
DIM i1 AS Integer
DIM i2 AS Integer

b1 = &H55
' Bad Argument, maximum = 7 for Byte for Integer : s2 = Shl(b1, 8) OR b2
i1 = Shl(CInt(b1), 16)
PRINT &quot;i1=&quot;; Hex$(i1)
i2 = Shl(b1, 16) ' Stops here with Bad Argument
PRINT &quot;   i2=&quot;; Hex$(i2)
<hr>i1=550000</pre>
<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>

