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

703 lines
8.5 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of Stdlib.Nativeint</TITLE>
</HEAD><BODY>
<H1>Stdlib.Nativeint</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>
Stdlib.Nativeint - no description
<A NAME="lbAC">&nbsp;</A>
<H2>Module</H2>
Module Stdlib.Nativeint
<A NAME="lbAD">&nbsp;</A>
<H2>Documentation</H2>
<P>
Module
<B>Nativeint</B>
<BR>&nbsp;:&nbsp;
<B>(module Stdlib__nativeint)</B>
<P>
<P>
<P>
<P>
<P>
<P>
<P>
<P>
<I>val zero </I>
:
<B>nativeint</B>
<P>
The native integer 0.
<P>
<P>
<P>
<I>val one </I>
:
<B>nativeint</B>
<P>
The native integer 1.
<P>
<P>
<P>
<I>val minus_one </I>
:
<B>nativeint</B>
<P>
The native integer -1.
<P>
<P>
<P>
<I>val neg </I>
:
<B>nativeint -&gt; nativeint</B>
<P>
Unary negation.
<P>
<P>
<P>
<I>val add </I>
:
<B>nativeint -&gt; nativeint -&gt; nativeint</B>
<P>
Addition.
<P>
<P>
<P>
<I>val sub </I>
:
<B>nativeint -&gt; nativeint -&gt; nativeint</B>
<P>
Subtraction.
<P>
<P>
<P>
<I>val mul </I>
:
<B>nativeint -&gt; nativeint -&gt; nativeint</B>
<P>
Multiplication.
<P>
<P>
<P>
<I>val div </I>
:
<B>nativeint -&gt; nativeint -&gt; nativeint</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>nativeint -&gt; nativeint -&gt; nativeint</B>
<P>
Same as
<B>Nativeint.div</B>
, except that arguments and result are interpreted as unsigned native integers.
<P>
<P>
<B>Since</B>
4.08.0
<P>
<P>
<P>
<I>val rem </I>
:
<B>nativeint -&gt; nativeint -&gt; nativeint</B>
<P>
Integer remainder. If
<B>y</B>
is not zero, the result
of
<B>Nativeint.rem x y</B>
satisfies the following properties:
<B>Nativeint.zero &lt;= Nativeint.rem x y &lt; Nativeint.abs y</B>
and
<B>x = Nativeint.add (Nativeint.mul (Nativeint.div x y) y)</B>
<B>(Nativeint.rem x y)</B>
.
If
<B>y = 0</B>
,
<B>Nativeint.rem x y</B>
raises
<B>Division_by_zero</B>
.
<P>
<P>
<P>
<I>val unsigned_rem </I>
:
<B>nativeint -&gt; nativeint -&gt; nativeint</B>
<P>
Same as
<B>Nativeint.rem</B>
, except that arguments and result are interpreted as unsigned native integers.
<P>
<P>
<B>Since</B>
4.08.0
<P>
<P>
<P>
<I>val succ </I>
:
<B>nativeint -&gt; nativeint</B>
<P>
Successor.
<B>Nativeint.succ x</B>
is
<B>Nativeint.add x Nativeint.one</B>
.
<P>
<P>
<P>
<I>val pred </I>
:
<B>nativeint -&gt; nativeint</B>
<P>
Predecessor.
<B>Nativeint.pred x</B>
is
<B>Nativeint.sub x Nativeint.one</B>
.
<P>
<P>
<P>
<I>val abs </I>
:
<B>nativeint -&gt; nativeint</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 native integer. This is equal to
<B>32</B>
on a 32-bit platform and to
<B>64</B>
on a 64-bit platform.
<P>
<P>
<P>
<I>val max_int </I>
:
<B>nativeint</B>
<P>
The greatest representable native 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>nativeint</B>
<P>
The smallest representable native 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>nativeint -&gt; nativeint -&gt; nativeint</B>
<P>
Bitwise logical and.
<P>
<P>
<P>
<I>val logor </I>
:
<B>nativeint -&gt; nativeint -&gt; nativeint</B>
<P>
Bitwise logical or.
<P>
<P>
<P>
<I>val logxor </I>
:
<B>nativeint -&gt; nativeint -&gt; nativeint</B>
<P>
Bitwise logical exclusive or.
<P>
<P>
<P>
<I>val lognot </I>
:
<B>nativeint -&gt; nativeint</B>
<P>
Bitwise logical negation.
<P>
<P>
<P>
<I>val shift_left </I>
:
<B>nativeint -&gt; int -&gt; nativeint</B>
<P>
<P>
<B>Nativeint.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>nativeint -&gt; int -&gt; nativeint</B>
<P>
<P>
<B>Nativeint.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>nativeint -&gt; int -&gt; nativeint</B>
<P>
<P>
<B>Nativeint.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; nativeint</B>
<P>
Convert the given integer (type
<B>int</B>
) to a native integer
(type
<B>nativeint</B>
).
<P>
<P>
<P>
<I>val to_int </I>
:
<B>nativeint -&gt; int</B>
<P>
Convert the given native integer (type
<B>nativeint</B>
) to an
integer (type
<B>int</B>
). The high-order bit is lost during
the conversion.
<P>
<P>
<P>
<I>val unsigned_to_int </I>
:
<B>nativeint -&gt; int option</B>
<P>
Same as
<B>Nativeint.to_int</B>
, but interprets the argument as an unsigned integer.
Returns
<B>None</B>
if the unsigned value of the argument cannot fit into an
<B>int</B>
.
<P>
<P>
<B>Since</B>
4.08.0
<P>
<P>
<P>
<I>val of_float </I>
:
<B>float -&gt; nativeint</B>
<P>
Convert the given floating-point number to a native 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>Nativeint.min_int</B>
,
<B>Nativeint.max_int</B>
].
<P>
<P>
<P>
<I>val to_float </I>
:
<B>nativeint -&gt; float</B>
<P>
Convert the given native integer to a floating-point number.
<P>
<P>
<P>
<I>val of_int32 </I>
:
<B>int32 -&gt; nativeint</B>
<P>
Convert the given 32-bit integer (type
<B>int32</B>
)
to a native integer.
<P>
<P>
<P>
<I>val to_int32 </I>
:
<B>nativeint -&gt; int32</B>
<P>
Convert the given native 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_string </I>
:
<B>string -&gt; nativeint</B>
<P>
Convert the given string to a native integer.
The string is read in decimal (by default, or if the string
begins with
<B>0u</B>
) or in hexadecimal, octal or binary if the
string begins with
<B>0x</B>
,
<B>0o</B>
or
<B>0b</B>
respectively.
<P>
The
<B>0u</B>
prefix reads the input as an unsigned integer in the range
<B>[0, 2*Nativeint.max_int+1]</B>
. If the input exceeds
<B>Nativeint.max_int</B>
it is converted to the signed integer
<B>Int64.min_int + input - Nativeint.max_int - 1</B>
.
<P>
Raise
<B>Failure Nativeint.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 of_string_opt </I>
:
<B>string -&gt; nativeint option</B>
<P>
Same as
<B>of_string</B>
, but return
<B>None</B>
instead of raising.
<P>
<P>
<B>Since</B>
4.05
<P>
<P>
<P>
<I>val to_string </I>
:
<B>nativeint -&gt; string</B>
<P>
Return the string representation of its argument, in decimal.
<P>
<P>
<I>type t </I>
=
<B>nativeint</B>
<P>
<P>
An alias for the type of native integers.
<P>
<P>
<P>
<I>val compare </I>
:
<B>t -&gt; t -&gt; int</B>
<P>
The comparison function for native 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>Nativeint</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>Nativeint.compare</B>
, except that arguments are interpreted as unsigned
native integers.
<P>
<P>
<B>Since</B>
4.08.0
<P>
<P>
<P>
<I>val equal </I>
:
<B>t -&gt; t -&gt; bool</B>
<P>
The equal function for native ints.
<P>
<P>
<B>Since</B>
4.03.0
<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:57 GMT, March 31, 2021
</BODY>
</HTML>