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

705 lines
8.3 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of Targetint</TITLE>
</HEAD><BODY>
<H1>Targetint</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>
Targetint - Target processor-native integers.
<A NAME="lbAC">&nbsp;</A>
<H2>Module</H2>
Module Targetint
<A NAME="lbAD">&nbsp;</A>
<H2>Documentation</H2>
<P>
Module
<B>Targetint</B>
<BR>&nbsp;:&nbsp;
<B>sig end</B>
<P>
<P>
Target processor-native integers.
<P>
This module provides operations on the type of
signed 32-bit integers (on 32-bit target platforms) or
signed 64-bit integers (on 64-bit target platforms).
This integer type has exactly the same width as that of a
pointer type in the C compiler. All arithmetic operations over
are taken modulo 2^32 or 2^64 depending
on the word size of the target architecture.
<P>
Warning: this module is unstable and part of
<B>Compiler_libs</B>
.
<P>
<P>
<P>
<P>
<P>
<I>type t </I>
<P>
<P>
The type of target integers.
<P>
<P>
<P>
<I>val zero </I>
:
<B>t</B>
<P>
The target integer 0.
<P>
<P>
<P>
<I>val one </I>
:
<B>t</B>
<P>
The target integer 1.
<P>
<P>
<P>
<I>val minus_one </I>
:
<B>t</B>
<P>
The target integer -1.
<P>
<P>
<P>
<I>val neg </I>
:
<B>t -&gt; t</B>
<P>
Unary negation.
<P>
<P>
<P>
<I>val add </I>
:
<B>t -&gt; t -&gt; t</B>
<P>
Addition.
<P>
<P>
<P>
<I>val sub </I>
:
<B>t -&gt; t -&gt; t</B>
<P>
Subtraction.
<P>
<P>
<P>
<I>val mul </I>
:
<B>t -&gt; t -&gt; t</B>
<P>
Multiplication.
<P>
<P>
<P>
<I>val div </I>
:
<B>t -&gt; t -&gt; t</B>
<P>
Integer division. Raise
<B>Division_by_zero</B>
if the second
argument is zero. This division rounds the real quotient of
its arguments towards zero, as specified for
<B>(/)</B>
.
<P>
<P>
<P>
<I>val unsigned_div </I>
:
<B>t -&gt; t -&gt; t</B>
<P>
Same as
<B>Targetint.div</B>
, except that arguments and result are interpreted as unsigned integers.
<P>
<P>
<P>
<I>val rem </I>
:
<B>t -&gt; t -&gt; t</B>
<P>
Integer remainder. If
<B>y</B>
is not zero, the result
of
<B>Targetint.rem x y</B>
satisfies the following properties:
<B>Targetint.zero &lt;= Nativeint.rem x y &lt; Targetint.abs y</B>
and
<B>x = Targetint.add (Targetint.mul (Targetint.div x y) y)</B>
<B>(Targetint.rem x y)</B>
.
If
<B>y = 0</B>
,
<B>Targetint.rem x y</B>
raises
<B>Division_by_zero</B>
.
<P>
<P>
<P>
<I>val unsigned_rem </I>
:
<B>t -&gt; t -&gt; t</B>
<P>
Same as
<B>Targetint.rem</B>
, except that arguments and result are interpreted as unsigned integers.
<P>
<P>
<P>
<I>val succ </I>
:
<B>t -&gt; t</B>
<P>
Successor.
<B>Targetint.succ x</B>
is
<B>Targetint.add x Targetint.one</B>
.
<P>
<P>
<P>
<I>val pred </I>
:
<B>t -&gt; t</B>
<P>
Predecessor.
<B>Targetint.pred x</B>
is
<B>Targetint.sub x Targetint.one</B>
.
<P>
<P>
<P>
<I>val abs </I>
:
<B>t -&gt; t</B>
<P>
Return the absolute value of its argument.
<P>
<P>
<P>
<I>val size </I>
:
<B>int</B>
<P>
The size in bits of a target native integer.
<P>
<P>
<P>
<I>val max_int </I>
:
<B>t</B>
<P>
The greatest representable target integer,
either 2^31 - 1 on a 32-bit platform,
or 2^63 - 1 on a 64-bit platform.
<P>
<P>
<P>
<I>val min_int </I>
:
<B>t</B>
<P>
The smallest representable target integer,
either -2^31 on a 32-bit platform,
or -2^63 on a 64-bit platform.
<P>
<P>
<P>
<I>val logand </I>
:
<B>t -&gt; t -&gt; t</B>
<P>
Bitwise logical and.
<P>
<P>
<P>
<I>val logor </I>
:
<B>t -&gt; t -&gt; t</B>
<P>
Bitwise logical or.
<P>
<P>
<P>
<I>val logxor </I>
:
<B>t -&gt; t -&gt; t</B>
<P>
Bitwise logical exclusive or.
<P>
<P>
<P>
<I>val lognot </I>
:
<B>t -&gt; t</B>
<P>
Bitwise logical negation.
<P>
<P>
<P>
<I>val shift_left </I>
:
<B>t -&gt; int -&gt; t</B>
<P>
<P>
<B>Targetint.shift_left x y</B>
shifts
<B>x</B>
to the left by
<B>y</B>
bits.
The result is unspecified if
<B>y &lt; 0</B>
or
<B>y &gt;= bitsize</B>
,
where
<B>bitsize</B>
is
<B>32</B>
on a 32-bit platform and
<B>64</B>
on a 64-bit platform.
<P>
<P>
<P>
<I>val shift_right </I>
:
<B>t -&gt; int -&gt; t</B>
<P>
<P>
<B>Targetint.shift_right x y</B>
shifts
<B>x</B>
to the right by
<B>y</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>y &lt; 0</B>
or
<B>y &gt;= bitsize</B>
.
<P>
<P>
<P>
<I>val shift_right_logical </I>
:
<B>t -&gt; int -&gt; t</B>
<P>
<P>
<B>Targetint.shift_right_logical x y</B>
shifts
<B>x</B>
to the right
by
<B>y</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>y &lt; 0</B>
or
<B>y &gt;= bitsize</B>
.
<P>
<P>
<P>
<I>val of_int </I>
:
<B>int -&gt; t</B>
<P>
Convert the given integer (type
<B>int</B>
) to a target integer
(type
<B>t</B>
), module the target word size.
<P>
<P>
<P>
<I>val of_int_exn </I>
:
<B>int -&gt; t</B>
<P>
Convert the given integer (type
<B>int</B>
) to a target integer
(type
<B>t</B>
). Raises a fatal error if the conversion is not exact.
<P>
<P>
<P>
<I>val to_int </I>
:
<B>t -&gt; int</B>
<P>
Convert the given target integer (type
<B>t</B>
) to an
integer (type
<B>int</B>
). The high-order bit is lost during
the conversion.
<P>
<P>
<P>
<I>val of_float </I>
:
<B>float -&gt; t</B>
<P>
Convert the given floating-point number to a target integer,
discarding the fractional part (truncate towards 0).
The result of the conversion is undefined if, after truncation,
the number is outside the range
[
<B>Targetint.min_int</B>
,
<B>Targetint.max_int</B>
].
<P>
<P>
<P>
<I>val to_float </I>
:
<B>t -&gt; float</B>
<P>
Convert the given target integer to a floating-point number.
<P>
<P>
<P>
<I>val of_int32 </I>
:
<B>int32 -&gt; t</B>
<P>
Convert the given 32-bit integer (type
<B>int32</B>
)
to a target integer.
<P>
<P>
<P>
<I>val to_int32 </I>
:
<B>t -&gt; int32</B>
<P>
Convert the given target integer to a
32-bit integer (type
<B>int32</B>
). On 64-bit platforms,
the 64-bit native integer is taken modulo 2^32,
i.e. the top 32 bits are lost. On 32-bit platforms,
the conversion is exact.
<P>
<P>
<P>
<I>val of_int64 </I>
:
<B>int64 -&gt; t</B>
<P>
Convert the given 64-bit integer (type
<B>int64</B>
)
to a target integer.
<P>
<P>
<P>
<I>val to_int64 </I>
:
<B>t -&gt; int64</B>
<P>
Convert the given target integer to a
64-bit integer (type
<B>int64</B>
).
<P>
<P>
<P>
<I>val of_string </I>
:
<B>string -&gt; t</B>
<P>
Convert the given string to a target integer.
The string is read in decimal (by default) or in hexadecimal,
octal or binary if the string begins with
<B>0x</B>
,
<B>0o</B>
or
<B>0b</B>
respectively.
Raise
<B>Failure int_of_string</B>
if the given string is not
a valid representation of an integer, or if the integer represented
exceeds the range of integers representable in type
<B>nativeint</B>
.
<P>
<P>
<P>
<I>val to_string </I>
:
<B>t -&gt; string</B>
<P>
Return the string representation of its argument, in decimal.
<P>
<P>
<P>
<I>val compare </I>
:
<B>t -&gt; t -&gt; int</B>
<P>
The comparison function for target integers, with the same specification as
<B>compare</B>
. Along with the type
<B>t</B>
, this function
<B>compare</B>
allows the module
<B>Targetint</B>
to be passed as argument to the functors
<B>Set.Make</B>
and
<B>Map.Make</B>
.
<P>
<P>
<P>
<I>val unsigned_compare </I>
:
<B>t -&gt; t -&gt; int</B>
<P>
Same as
<B>Targetint.compare</B>
, except that arguments are interpreted as unsigned
integers.
<P>
<P>
<P>
<I>val equal </I>
:
<B>t -&gt; t -&gt; bool</B>
<P>
The equal function for target ints.
<P>
<P>
<I>type repr </I>
=
<BR>&nbsp;|&nbsp;Int32
<B>of </B>
<B>int32</B>
<BR>&nbsp;|&nbsp;Int64
<B>of </B>
<B>int64</B>
<BR>&nbsp;
<P>
<P>
<P>
<P>
<I>val repr </I>
:
<B>t -&gt; repr</B>
<P>
The concrete representation of a native integer.
<P>
<P>
<P>
<I>val print </I>
:
<B>Format.formatter -&gt; t -&gt; unit</B>
<P>
Print a target integer to a formatter.
<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>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:58 GMT, March 31, 2021
</BODY>
</HTML>