705 lines
8.3 KiB
HTML
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"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
Targetint - Target processor-native integers.
|
|
<A NAME="lbAC"> </A>
|
|
<H2>Module</H2>
|
|
|
|
Module Targetint
|
|
<A NAME="lbAD"> </A>
|
|
<H2>Documentation</H2>
|
|
|
|
<P>
|
|
Module
|
|
<B>Targetint</B>
|
|
|
|
<BR> :
|
|
<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 -> t</B>
|
|
|
|
<P>
|
|
Unary negation.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val add </I>
|
|
|
|
:
|
|
<B>t -> t -> t</B>
|
|
|
|
<P>
|
|
Addition.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val sub </I>
|
|
|
|
:
|
|
<B>t -> t -> t</B>
|
|
|
|
<P>
|
|
Subtraction.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val mul </I>
|
|
|
|
:
|
|
<B>t -> t -> t</B>
|
|
|
|
<P>
|
|
Multiplication.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val div </I>
|
|
|
|
:
|
|
<B>t -> t -> 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 -> t -> 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 -> t -> 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 <= Nativeint.rem x y < 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 -> t -> 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 -> 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 -> 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 -> 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 -> t -> t</B>
|
|
|
|
<P>
|
|
Bitwise logical and.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val logor </I>
|
|
|
|
:
|
|
<B>t -> t -> t</B>
|
|
|
|
<P>
|
|
Bitwise logical or.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val logxor </I>
|
|
|
|
:
|
|
<B>t -> t -> t</B>
|
|
|
|
<P>
|
|
Bitwise logical exclusive or.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val lognot </I>
|
|
|
|
:
|
|
<B>t -> t</B>
|
|
|
|
<P>
|
|
Bitwise logical negation.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val shift_left </I>
|
|
|
|
:
|
|
<B>t -> int -> 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 < 0</B>
|
|
|
|
or
|
|
<B>y >= 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 -> int -> 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 < 0</B>
|
|
|
|
or
|
|
<B>y >= bitsize</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val shift_right_logical </I>
|
|
|
|
:
|
|
<B>t -> int -> 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 < 0</B>
|
|
|
|
or
|
|
<B>y >= bitsize</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val of_int </I>
|
|
|
|
:
|
|
<B>int -> 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 -> 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 -> 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 -> 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 -> float</B>
|
|
|
|
<P>
|
|
Convert the given target integer to a floating-point number.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val of_int32 </I>
|
|
|
|
:
|
|
<B>int32 -> 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 -> 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 -> 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 -> 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 -> 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 -> string</B>
|
|
|
|
<P>
|
|
Return the string representation of its argument, in decimal.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val compare </I>
|
|
|
|
:
|
|
<B>t -> t -> 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 -> t -> 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 -> t -> bool</B>
|
|
|
|
<P>
|
|
The equal function for target ints.
|
|
<P>
|
|
<P>
|
|
<I>type repr </I>
|
|
|
|
=
|
|
<BR> | Int32
|
|
<B>of </B>
|
|
|
|
<B>int32</B>
|
|
|
|
<BR> | Int64
|
|
<B>of </B>
|
|
|
|
<B>int64</B>
|
|
|
|
<BR>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val repr </I>
|
|
|
|
:
|
|
<B>t -> repr</B>
|
|
|
|
<P>
|
|
The concrete representation of a native integer.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val print </I>
|
|
|
|
:
|
|
<B>Format.formatter -> t -> unit</B>
|
|
|
|
<P>
|
|
Print a target integer to a formatter.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </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>
|