<!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 - Hex$
</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="goto+en">Previous</a>&nbsp;
<a href="hour+en">Next</a>&nbsp;
</td></tr></table>
<div class="notab">
<h1>
Hex$
</h1>
<div class="black"><font size="-2"><b>Syntax</b></font></div>
<pre class="syntax"><u>String</u> <b>= Hex$ (</b> <u>Number</u> AS Long [ <b>,</b> <u>Digits</u> AS Integer ] <b>)</b></pre><p>

Gets the hexadecimal representation of a number.
<p>
If <u>Digits</u> is specified, the representation is padded with unnecessary zeros so that <u>Digits</u> digits are returned.
<p>
<div class="gray"><font size="-2"><b>Example</b></font></div>
<pre class="example">PRINT Hex$(1972)
<hr>7B4</pre>
<div class="gray"><font size="-2"><b>Example</b></font></div>
<pre class="example">PRINT Hex$(1972, 8)
<hr>000007B4</pre>
<p>
The sign of a <a href="type/short+en">Short</a> or <a href="type/integer+en">Integer</a> will be extended, because the <u>Number</u> will be extended to <a href="type/long+en">Long</a> .
If the hexadecimal representation should be limited to 16 bits the <a href="and+en">AND</a> operator must be used.
<p>
<div class="gray"><font size="-2"><b>Example</b></font></div>
<pre class="example">DIM bX AS Byte ' 8 bits unsigned
DIM sX AS Short ' 16 Bits signed

bX = 200
sX = -456
PRINT Hex$(bX), Hex$(sX), Hex$(CLong(sX) AND &hffff&)
<hr>C8	FFFFFFFFFFFFFE38	FE38</pre>
<p>

<hr><b>See also</b><br>
<a href="../cat/format+en">Formatting functions</a>&nbsp;

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

