man-pages/man3/Int.3o.html
2021-03-31 01:06:50 +01:00

610 lines
5.6 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of Int</TITLE>
</HEAD><BODY>
<H1>Int</H1>
Section: OCaml library (3o)<BR>Updated: 2020-01-30<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
Int - Integer values.
<A NAME="lbAC">&nbsp;</A>
<H2>Module</H2>
Module Int
<A NAME="lbAD">&nbsp;</A>
<H2>Documentation</H2>
<P>
Module
<B>Int</B>
<BR>&nbsp;:&nbsp;
<B>sig end</B>
<P>
<P>
Integer values.
<P>
Integers are
<B>Sys.int_size</B>
bits wide and use two's complement
representation. All operations are taken modulo
2^
<B>Sys.int_size</B>
. They do not fail on overflow.
<P>
<P>
<B>Since</B>
4.08
<P>
<P>
<P>
<P>
<P>
<P>
<P>
<A NAME="lbAE">&nbsp;</A>
<H3>Integers</H3>
<P>
<P>
<I>type t </I>
=
<B>int</B>
<P>
<P>
The type for integer values.
<P>
<P>
<P>
<I>val zero </I>
:
<B>int</B>
<P>
<P>
<B>zero</B>
is the integer
<B>0</B>
.
<P>
<P>
<P>
<I>val one </I>
:
<B>int</B>
<P>
<P>
<B>one</B>
is the integer
<B>1</B>
.
<P>
<P>
<P>
<I>val minus_one </I>
:
<B>int</B>
<P>
<P>
<B>minus_one</B>
is the integer
<B>-1</B>
.
<P>
<P>
<P>
<I>val neg </I>
:
<B>int -&gt; int</B>
<P>
<P>
<B>neg x</B>
is
<B>~-x</B>
.
<P>
<P>
<P>
<I>val add </I>
:
<B>int -&gt; int -&gt; int</B>
<P>
<P>
<B>add x y</B>
is the addition
<B>x + y</B>
.
<P>
<P>
<P>
<I>val sub </I>
:
<B>int -&gt; int -&gt; int</B>
<P>
<P>
<B>sub x y</B>
is the subtraction
<B>x - y</B>
.
<P>
<P>
<P>
<I>val mul </I>
:
<B>int -&gt; int -&gt; int</B>
<P>
<P>
<B>mul x y</B>
is the multiplication
<B>x * y</B>
.
<P>
<P>
<P>
<I>val div </I>
:
<B>int -&gt; int -&gt; int</B>
<P>
<P>
<B>div x y</B>
is the division
<B>x / y</B>
. See
<B>(/)</B>
for details.
<P>
<P>
<P>
<I>val rem </I>
:
<B>int -&gt; int -&gt; int</B>
<P>
<P>
<B>rem x y</B>
is the remainder
<B>x mod y</B>
. See
<B>(mod)</B>
for details.
<P>
<P>
<P>
<I>val succ </I>
:
<B>int -&gt; int</B>
<P>
<P>
<B>succ x</B>
is
<B>add x 1</B>
.
<P>
<P>
<P>
<I>val pred </I>
:
<B>int -&gt; int</B>
<P>
<P>
<B>pred x</B>
is
<B>sub x 1</B>
.
<P>
<P>
<P>
<I>val abs </I>
:
<B>int -&gt; int</B>
<P>
<P>
<B>abs x</B>
is the absolute value of
<B>x</B>
. That is
<B>x</B>
if
<B>x</B>
is positive
and
<B>neg x</B>
if
<B>x</B>
is negative. Warning. This may be negative if
the argument is
<B>Int.min_int</B>
.
<P>
<P>
<P>
<I>val max_int </I>
:
<B>int</B>
<P>
<P>
<B>max_int</B>
is the greatest representable integer,
<B>2{^[Sys.int_size - 1]} - 1</B>
.
<P>
<P>
<P>
<I>val min_int </I>
:
<B>int</B>
<P>
<P>
<B>min_int</B>
is the smallest representable integer,
<B>-2{^[Sys.int_size - 1]}</B>
.
<P>
<P>
<P>
<I>val logand </I>
:
<B>int -&gt; int -&gt; int</B>
<P>
<P>
<B>logand x y</B>
is the bitwise logical and of
<B>x</B>
and
<B>y</B>
.
<P>
<P>
<P>
<I>val logor </I>
:
<B>int -&gt; int -&gt; int</B>
<P>
<P>
<B>logor x y</B>
is the bitwise logical or of
<B>x</B>
and
<B>y</B>
.
<P>
<P>
<P>
<I>val logxor </I>
:
<B>int -&gt; int -&gt; int</B>
<P>
<P>
<B>logxor x y</B>
is the bitwise logical exclusive or of
<B>x</B>
and
<B>y</B>
.
<P>
<P>
<P>
<I>val lognot </I>
:
<B>int -&gt; int</B>
<P>
<P>
<B>lognot x</B>
is the bitwise logical negation of
<B>x</B>
.
<P>
<P>
<P>
<I>val shift_left </I>
:
<B>int -&gt; int -&gt; int</B>
<P>
<P>
<B>shift_left x n</B>
shifts
<B>x</B>
to the left by
<B>n</B>
bits. The result
is unspecified if
<B>n &lt; 0</B>
or
<B>n &gt; </B>
<B>Sys.int_size</B>
.
<P>
<P>
<P>
<I>val shift_right </I>
:
<B>int -&gt; int -&gt; int</B>
<P>
<P>
<B>shift_right x n</B>
shifts
<B>x</B>
to the right by
<B>n</B>
bits. This is an
arithmetic shift: the sign bit of
<B>x</B>
is replicated and inserted
in the vacated bits. The result is unspecified if
<B>n &lt; 0</B>
or
<B>n &gt; </B>
<B>Sys.int_size</B>
.
<P>
<P>
<P>
<I>val shift_right_logical </I>
:
<B>int -&gt; int -&gt; int</B>
<P>
<P>
<B>shift_right x n</B>
shifts
<B>x</B>
to the right by
<B>n</B>
bits. This is a
logical shift: zeroes are inserted in the vacated bits regardless
of the sign of
<B>x</B>
. The result is unspecified if
<B>n &lt; 0</B>
or
<B>n &gt; </B>
<B>Sys.int_size</B>
.
<P>
<P>
<P>
<P>
<A NAME="lbAF">&nbsp;</A>
<H3>Predicates and comparisons</H3>
<P>
<P>
<P>
<I>val equal </I>
:
<B>int -&gt; int -&gt; bool</B>
<P>
<P>
<B>equal x y</B>
is
<B>true</B>
iff
<B>x = y</B>
.
<P>
<P>
<P>
<I>val compare </I>
:
<B>int -&gt; int -&gt; int</B>
<P>
<P>
<B>compare x y</B>
is
<B>compare</B>
<B>x y</B>
but more efficient.
<P>
<P>
<P>
<P>
<A NAME="lbAG">&nbsp;</A>
<H3>Converting</H3>
<P>
<P>
<P>
<I>val to_float </I>
:
<B>int -&gt; float</B>
<P>
<P>
<B>to_float x</B>
is
<B>x</B>
as a floating point number.
<P>
<P>
<P>
<I>val of_float </I>
:
<B>float -&gt; int</B>
<P>
<P>
<B>of_float x</B>
truncates
<B>x</B>
to an integer. The result is
unspecified if the argument is
<B>nan</B>
or falls outside the range of
representable integers.
<P>
<P>
<P>
<I>val to_string </I>
:
<B>int -&gt; string</B>
<P>
<P>
<B>to_string x</B>
is the written representation of
<B>x</B>
in decimal.
<P>
<P>
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="1"><A HREF="#lbAB">NAME</A><DD>
<DT id="2"><A HREF="#lbAC">Module</A><DD>
<DT id="3"><A HREF="#lbAD">Documentation</A><DD>
<DL>
<DT id="4"><A HREF="#lbAE">Integers</A><DD>
<DT id="5"><A HREF="#lbAF">Predicates and comparisons</A><DD>
<DT id="6"><A HREF="#lbAG">Converting</A><DD>
</DL>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:46 GMT, March 31, 2021
</BODY>
</HTML>