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

Returns the mathematical integer part of <u>Number</u>, i.e. the greatest integer which is less than <u>Number</u>.
<p>
<div class="gray"><font size="-2"><b>Example</b></font></div>
<pre class="example">PRINT Int(Pi)
<hr>3</pre>
<div class="gray"><font size="-2"><b>Example</b></font></div>
<pre class="example">PRINT Int(-Pi)
<hr>-4</pre>
<p>
The <u>Value</u> is not limited to the <a href="type/integer+en">Integer</a> size (32 bits) nor to the <a href="type/long+en">Long</a> size (64 bits). It may be <a href="type/float+en">Float</a>.
<div class="gray"><font size="-2"><b>Example</b></font></div>
<pre class="example">PRINT Int(2e60), CInt(2e60)
<hr>2E+60	-2147483648</pre>
<p>
The next example shows how Int() works on a <a href="type/boolean+en">Boolean</a> variable.
<div class="gray"><font size="-2"><b>Example</b></font></div>
<pre class="example">PRINT Int(TRUE)
<hr>True</pre>
<p>
The Difference between Int() and <a href="cint+en">CInt</a>() is:
<ul>
<li>Int() may return a <a href="type/float+en">Float</a> value, <a href="cint+en">CInt</a>() is limited to 32 bit <a href="type/integer+en">Integer</a>.
<li>Int() rounds to the next lower value. i.e. -4.6 to -5, while <a href="cint+en">CInt</a> rounds toward 0 i.e. -4.6 to -4
<p>

</ul>

<hr><b>See also</b><br>
<a href="../cat/arith+en">Arithmetical Functions</a>&nbsp;

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

