<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../style.css">
<title>
Gambas Documentation - Shl
</title>
</head>
<body>
<table class="none" width="100%" cellpadding="0" cellspacing="0" border="0">
<tr><td align="left">
<font size="-1">
<a href="../../help%3Fen"><img class="flag" alt="Home" border="0" src="../../img/lang/en.png" align="center"></a>&nbsp;&nbsp;
<a href="../lang%3Fen">Up</a>&nbsp;&nbsp;
<a href="asinh%3Fen">Previous</a>&nbsp;&nbsp;
<a href="asr%3Fen">Next</a>&nbsp;&nbsp;
</td></tr></table>
<div class="notab">
<h1>
Shl
</h1>
<div class="black"><font color="white" 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>
<u>Value</u> <b>= Asl (</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%3Fen">Byte</a>, <a href="type/short%3Fen">Short</a>, <a href="type/integer%3Fen">Integer</a>, or <a href="type/long%3Fen">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 bgcolor="white"><td valign="top">
<a href="type/byte%3Fen">Byte</a>
</td><td valign="top">
0...7
</td></tr>
<tr><td valign="top">
<a href="type/short%3Fen">Short</a>
</td><td valign="top">
0...15
</td></tr>
<tr bgcolor="white"><td valign="top">
<a href="type/integer%3Fen">Integer</a>
</td><td valign="top">
0...31
</td></tr>
<tr><td valign="top">
<a href="type/long%3Fen">Long</a>
</td><td valign="top">
0...63
</td></tr>
</table>
<p>
<div class="gray"><font color="white" 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%3Fen">CLong</a>, <a href="cint%3Fen">CInt</a>, <a href="cshort%3Fen">CShort</a>
<p>
<div class="gray"><font color="white" 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%3Fen">Bits Manipulation Functions</a>&nbsp;&nbsp; <a href="../cat/logicop%3Fen">Logical Operators</a>&nbsp;&nbsp;

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

