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

672 lines
8.0 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of Stdlib.Int32</TITLE>
</HEAD><BODY>
<H1>Stdlib.Int32</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.Int32 - no description
<A NAME="lbAC">&nbsp;</A>
<H2>Module</H2>
Module Stdlib.Int32
<A NAME="lbAD">&nbsp;</A>
<H2>Documentation</H2>
<P>
Module
<B>Int32</B>
<BR>&nbsp;:&nbsp;
<B>(module Stdlib__int32)</B>
<P>
<P>
<P>
<P>
<P>
<P>
<P>
<P>
<I>val zero </I>
:
<B>int32</B>
<P>
The 32-bit integer 0.
<P>
<P>
<P>
<I>val one </I>
:
<B>int32</B>
<P>
The 32-bit integer 1.
<P>
<P>
<P>
<I>val minus_one </I>
:
<B>int32</B>
<P>
The 32-bit integer -1.
<P>
<P>
<P>
<I>val neg </I>
:
<B>int32 -&gt; int32</B>
<P>
Unary negation.
<P>
<P>
<P>
<I>val add </I>
:
<B>int32 -&gt; int32 -&gt; int32</B>
<P>
Addition.
<P>
<P>
<P>
<I>val sub </I>
:
<B>int32 -&gt; int32 -&gt; int32</B>
<P>
Subtraction.
<P>
<P>
<P>
<I>val mul </I>
:
<B>int32 -&gt; int32 -&gt; int32</B>
<P>
Multiplication.
<P>
<P>
<P>
<I>val div </I>
:
<B>int32 -&gt; int32 -&gt; int32</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>int32 -&gt; int32 -&gt; int32</B>
<P>
Same as
<B>Int32.div</B>
, except that arguments and result are interpreted as unsigned 32-bit integers.
<P>
<P>
<B>Since</B>
4.08.0
<P>
<P>
<P>
<I>val rem </I>
:
<B>int32 -&gt; int32 -&gt; int32</B>
<P>
Integer remainder. If
<B>y</B>
is not zero, the result
of
<B>Int32.rem x y</B>
satisfies the following property:
<B>x = Int32.add (Int32.mul (Int32.div x y) y) (Int32.rem x y)</B>
.
If
<B>y = 0</B>
,
<B>Int32.rem x y</B>
raises
<B>Division_by_zero</B>
.
<P>
<P>
<P>
<I>val unsigned_rem </I>
:
<B>int32 -&gt; int32 -&gt; int32</B>
<P>
Same as
<B>Int32.rem</B>
, except that arguments and result are interpreted as unsigned 32-bit integers.
<P>
<P>
<B>Since</B>
4.08.0
<P>
<P>
<P>
<I>val succ </I>
:
<B>int32 -&gt; int32</B>
<P>
Successor.
<B>Int32.succ x</B>
is
<B>Int32.add x Int32.one</B>
.
<P>
<P>
<P>
<I>val pred </I>
:
<B>int32 -&gt; int32</B>
<P>
Predecessor.
<B>Int32.pred x</B>
is
<B>Int32.sub x Int32.one</B>
.
<P>
<P>
<P>
<I>val abs </I>
:
<B>int32 -&gt; int32</B>
<P>
Return the absolute value of its argument.
<P>
<P>
<P>
<I>val max_int </I>
:
<B>int32</B>
<P>
The greatest representable 32-bit integer, 2^31 - 1.
<P>
<P>
<P>
<I>val min_int </I>
:
<B>int32</B>
<P>
The smallest representable 32-bit integer, -2^31.
<P>
<P>
<P>
<I>val logand </I>
:
<B>int32 -&gt; int32 -&gt; int32</B>
<P>
Bitwise logical and.
<P>
<P>
<P>
<I>val logor </I>
:
<B>int32 -&gt; int32 -&gt; int32</B>
<P>
Bitwise logical or.
<P>
<P>
<P>
<I>val logxor </I>
:
<B>int32 -&gt; int32 -&gt; int32</B>
<P>
Bitwise logical exclusive or.
<P>
<P>
<P>
<I>val lognot </I>
:
<B>int32 -&gt; int32</B>
<P>
Bitwise logical negation.
<P>
<P>
<P>
<I>val shift_left </I>
:
<B>int32 -&gt; int -&gt; int32</B>
<P>
<P>
<B>Int32.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;= 32</B>
.
<P>
<P>
<P>
<I>val shift_right </I>
:
<B>int32 -&gt; int -&gt; int32</B>
<P>
<P>
<B>Int32.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;= 32</B>
.
<P>
<P>
<P>
<I>val shift_right_logical </I>
:
<B>int32 -&gt; int -&gt; int32</B>
<P>
<P>
<B>Int32.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;= 32</B>
.
<P>
<P>
<P>
<I>val of_int </I>
:
<B>int -&gt; int32</B>
<P>
Convert the given integer (type
<B>int</B>
) to a 32-bit integer
(type
<B>int32</B>
). On 64-bit platforms, the argument is taken
modulo 2^32.
<P>
<P>
<P>
<I>val to_int </I>
:
<B>int32 -&gt; int</B>
<P>
Convert the given 32-bit integer (type
<B>int32</B>
) to an
integer (type
<B>int</B>
). On 32-bit platforms, the 32-bit integer
is taken modulo 2^31, i.e. the high-order bit is lost
during the conversion. On 64-bit platforms, the conversion
is exact.
<P>
<P>
<P>
<I>val unsigned_to_int </I>
:
<B>int32 -&gt; int option</B>
<P>
Same as
<B>Int32.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; int32</B>
<P>
Convert the given floating-point number to a 32-bit 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>Int32.min_int</B>
,
<B>Int32.max_int</B>
].
<P>
<P>
<P>
<I>val to_float </I>
:
<B>int32 -&gt; float</B>
<P>
Convert the given 32-bit integer to a floating-point number.
<P>
<P>
<P>
<I>val of_string </I>
:
<B>string -&gt; int32</B>
<P>
Convert the given string to a 32-bit 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*Int32.max_int+1]</B>
. If the input exceeds
<B>Int32.max_int</B>
it is converted to the signed integer
<B>Int32.min_int + input - Int32.max_int - 1</B>
.
<P>
The
<B>_</B>
(underscore) character can appear anywhere in the string
and is ignored.
Raise
<B>Failure Int32.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>int32</B>
.
<P>
<P>
<P>
<I>val of_string_opt </I>
:
<B>string -&gt; int32 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>int32 -&gt; string</B>
<P>
Return the string representation of its argument, in signed decimal.
<P>
<P>
<P>
<I>val bits_of_float </I>
:
<B>float -&gt; int32</B>
<P>
Return the internal representation of the given float according
to the IEEE 754 floating-point 'single format' bit layout.
Bit 31 of the result represents the sign of the float;
bits 30 to 23 represent the (biased) exponent; bits 22 to 0
represent the mantissa.
<P>
<P>
<P>
<I>val float_of_bits </I>
:
<B>int32 -&gt; float</B>
<P>
Return the floating-point number whose internal representation,
according to the IEEE 754 floating-point 'single format' bit layout,
is the given
<B>int32</B>
.
<P>
<P>
<I>type t </I>
=
<B>int32</B>
<P>
<P>
An alias for the type of 32-bit integers.
<P>
<P>
<P>
<I>val compare </I>
:
<B>t -&gt; t -&gt; int</B>
<P>
The comparison function for 32-bit 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>Int32</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>Int32.compare</B>
, except that arguments are interpreted as unsigned
32-bit 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 int32s.
<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>