1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
|
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="Start" href="index.html">
<link rel="previous" href="ArrayLabels.html">
<link rel="next" href="Bigarray.html">
<link rel="Up" href="index.html">
<link title="Index of types" rel=Appendix href="index_types.html">
<link title="Index of exceptions" rel=Appendix href="index_exceptions.html">
<link title="Index of values" rel=Appendix href="index_values.html">
<link title="Index of modules" rel=Appendix href="index_modules.html">
<link title="Index of module types" rel=Appendix href="index_module_types.html">
<link title="Arg" rel="Chapter" href="Arg.html">
<link title="Arith_status" rel="Chapter" href="Arith_status.html">
<link title="Array" rel="Chapter" href="Array.html">
<link title="ArrayLabels" rel="Chapter" href="ArrayLabels.html">
<link title="Big_int" rel="Chapter" href="Big_int.html">
<link title="Bigarray" rel="Chapter" href="Bigarray.html">
<link title="Buffer" rel="Chapter" href="Buffer.html">
<link title="Callback" rel="Chapter" href="Callback.html">
<link title="CamlinternalMod" rel="Chapter" href="CamlinternalMod.html">
<link title="CamlinternalOO" rel="Chapter" href="CamlinternalOO.html">
<link title="Char" rel="Chapter" href="Char.html">
<link title="Complex" rel="Chapter" href="Complex.html">
<link title="Condition" rel="Chapter" href="Condition.html">
<link title="Dbm" rel="Chapter" href="Dbm.html">
<link title="Digest" rel="Chapter" href="Digest.html">
<link title="Dynlink" rel="Chapter" href="Dynlink.html">
<link title="Event" rel="Chapter" href="Event.html">
<link title="Filename" rel="Chapter" href="Filename.html">
<link title="Format" rel="Chapter" href="Format.html">
<link title="Gc" rel="Chapter" href="Gc.html">
<link title="Genlex" rel="Chapter" href="Genlex.html">
<link title="Graphics" rel="Chapter" href="Graphics.html">
<link title="GraphicsX11" rel="Chapter" href="GraphicsX11.html">
<link title="Hashtbl" rel="Chapter" href="Hashtbl.html">
<link title="Int32" rel="Chapter" href="Int32.html">
<link title="Int64" rel="Chapter" href="Int64.html">
<link title="Lazy" rel="Chapter" href="Lazy.html">
<link title="Lexing" rel="Chapter" href="Lexing.html">
<link title="List" rel="Chapter" href="List.html">
<link title="ListLabels" rel="Chapter" href="ListLabels.html">
<link title="Map" rel="Chapter" href="Map.html">
<link title="Marshal" rel="Chapter" href="Marshal.html">
<link title="MoreLabels" rel="Chapter" href="MoreLabels.html">
<link title="Mutex" rel="Chapter" href="Mutex.html">
<link title="Nativeint" rel="Chapter" href="Nativeint.html">
<link title="Num" rel="Chapter" href="Num.html">
<link title="Obj" rel="Chapter" href="Obj.html">
<link title="Oo" rel="Chapter" href="Oo.html">
<link title="Parsing" rel="Chapter" href="Parsing.html">
<link title="Pervasives" rel="Chapter" href="Pervasives.html">
<link title="Printexc" rel="Chapter" href="Printexc.html">
<link title="Printf" rel="Chapter" href="Printf.html">
<link title="Queue" rel="Chapter" href="Queue.html">
<link title="Random" rel="Chapter" href="Random.html">
<link title="Scanf" rel="Chapter" href="Scanf.html">
<link title="Set" rel="Chapter" href="Set.html">
<link title="Sort" rel="Chapter" href="Sort.html">
<link title="Stack" rel="Chapter" href="Stack.html">
<link title="StdLabels" rel="Chapter" href="StdLabels.html">
<link title="Str" rel="Chapter" href="Str.html">
<link title="Stream" rel="Chapter" href="Stream.html">
<link title="String" rel="Chapter" href="String.html">
<link title="StringLabels" rel="Chapter" href="StringLabels.html">
<link title="Sys" rel="Chapter" href="Sys.html">
<link title="Thread" rel="Chapter" href="Thread.html">
<link title="ThreadUnix" rel="Chapter" href="ThreadUnix.html">
<link title="Unix" rel="Chapter" href="Unix.html">
<link title="UnixLabels" rel="Chapter" href="UnixLabels.html">
<link title="Weak" rel="Chapter" href="Weak.html"><link title="Arithmetic operations" rel="Section" href="#6_Arithmeticoperations">
<link title="Comparisons and tests" rel="Section" href="#6_Comparisonsandtests">
<link title="Conversions to and from strings" rel="Section" href="#6_Conversionstoandfromstrings">
<link title="Conversions to and from other numerical types" rel="Section" href="#6_Conversionstoandfromothernumericaltypes">
<title>Big_int</title>
</head>
<body>
<div class="navbar"><a href="ArrayLabels.html">Previous</a>
<a href="index.html">Up</a>
<a href="Bigarray.html">Next</a>
</div>
<center><h1>Module <a href="type_Big_int.html">Big_int</a></h1></center>
<br>
<pre><span class="keyword">module</span> Big_int: <code class="code"><span class="keyword">sig</span></code> <a href="Big_int.html">..</a> <code class="code"><span class="keyword">end</span></code></pre>Operations on arbitrary-precision integers.
<p>
Big integers (type <code class="code">big_int</code>) are signed integers of arbitrary size.<br>
<hr width="100%">
<pre><span class="keyword">type</span> <a name="TYPEbig_int"></a><code class="type"></code>big_int </pre>
<div class="info">
The type of big integers.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALzero_big_int"></a>zero_big_int : <code class="type"><a href="Big_int.html#TYPEbig_int">big_int</a></code></pre><div class="info">
The big integer <code class="code">0</code>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALunit_big_int"></a>unit_big_int : <code class="type"><a href="Big_int.html#TYPEbig_int">big_int</a></code></pre><div class="info">
The big integer <code class="code">1</code>.<br>
</div>
<br>
<a name="6_Arithmeticoperations"></a>
<h6>Arithmetic operations</h6><br>
<pre><span class="keyword">val</span> <a name="VALminus_big_int"></a>minus_big_int : <code class="type"><a href="Big_int.html#TYPEbig_int">big_int</a> -> <a href="Big_int.html#TYPEbig_int">big_int</a></code></pre><div class="info">
Unary negation.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALabs_big_int"></a>abs_big_int : <code class="type"><a href="Big_int.html#TYPEbig_int">big_int</a> -> <a href="Big_int.html#TYPEbig_int">big_int</a></code></pre><div class="info">
Absolute value.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALadd_big_int"></a>add_big_int : <code class="type"><a href="Big_int.html#TYPEbig_int">big_int</a> -> <a href="Big_int.html#TYPEbig_int">big_int</a> -> <a href="Big_int.html#TYPEbig_int">big_int</a></code></pre><div class="info">
Addition.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALsucc_big_int"></a>succ_big_int : <code class="type"><a href="Big_int.html#TYPEbig_int">big_int</a> -> <a href="Big_int.html#TYPEbig_int">big_int</a></code></pre><div class="info">
Successor (add 1).<br>
</div>
<pre><span class="keyword">val</span> <a name="VALadd_int_big_int"></a>add_int_big_int : <code class="type">int -> <a href="Big_int.html#TYPEbig_int">big_int</a> -> <a href="Big_int.html#TYPEbig_int">big_int</a></code></pre><div class="info">
Addition of a small integer to a big integer.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALsub_big_int"></a>sub_big_int : <code class="type"><a href="Big_int.html#TYPEbig_int">big_int</a> -> <a href="Big_int.html#TYPEbig_int">big_int</a> -> <a href="Big_int.html#TYPEbig_int">big_int</a></code></pre><div class="info">
Subtraction.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALpred_big_int"></a>pred_big_int : <code class="type"><a href="Big_int.html#TYPEbig_int">big_int</a> -> <a href="Big_int.html#TYPEbig_int">big_int</a></code></pre><div class="info">
Predecessor (subtract 1).<br>
</div>
<pre><span class="keyword">val</span> <a name="VALmult_big_int"></a>mult_big_int : <code class="type"><a href="Big_int.html#TYPEbig_int">big_int</a> -> <a href="Big_int.html#TYPEbig_int">big_int</a> -> <a href="Big_int.html#TYPEbig_int">big_int</a></code></pre><div class="info">
Multiplication of two big integers.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALmult_int_big_int"></a>mult_int_big_int : <code class="type">int -> <a href="Big_int.html#TYPEbig_int">big_int</a> -> <a href="Big_int.html#TYPEbig_int">big_int</a></code></pre><div class="info">
Multiplication of a big integer by a small integer<br>
</div>
<pre><span class="keyword">val</span> <a name="VALsquare_big_int"></a>square_big_int : <code class="type"><a href="Big_int.html#TYPEbig_int">big_int</a> -> <a href="Big_int.html#TYPEbig_int">big_int</a></code></pre><div class="info">
Return the square of the given big integer<br>
</div>
<pre><span class="keyword">val</span> <a name="VALsqrt_big_int"></a>sqrt_big_int : <code class="type"><a href="Big_int.html#TYPEbig_int">big_int</a> -> <a href="Big_int.html#TYPEbig_int">big_int</a></code></pre><div class="info">
<code class="code">sqrt_big_int a</code> returns the integer square root of <code class="code">a</code>,
that is, the largest big integer <code class="code">r</code> such that <code class="code">r * r <= a</code>.
Raise <code class="code"><span class="constructor">Invalid_argument</span></code> if <code class="code">a</code> is negative.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALquomod_big_int"></a>quomod_big_int : <code class="type"><a href="Big_int.html#TYPEbig_int">big_int</a> -> <a href="Big_int.html#TYPEbig_int">big_int</a> -> <a href="Big_int.html#TYPEbig_int">big_int</a> * <a href="Big_int.html#TYPEbig_int">big_int</a></code></pre><div class="info">
Euclidean division of two big integers.
The first part of the result is the quotient,
the second part is the remainder.
Writing <code class="code">(q,r) = quomod_big_int a b</code>, we have
<code class="code">a = q * b + r</code> and <code class="code">0 <= r < <span class="keywordsign">|</span>b<span class="keywordsign">|</span></code>.
Raise <code class="code"><span class="constructor">Division_by_zero</span></code> if the divisor is zero.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALdiv_big_int"></a>div_big_int : <code class="type"><a href="Big_int.html#TYPEbig_int">big_int</a> -> <a href="Big_int.html#TYPEbig_int">big_int</a> -> <a href="Big_int.html#TYPEbig_int">big_int</a></code></pre><div class="info">
Euclidean quotient of two big integers.
This is the first result <code class="code">q</code> of <code class="code">quomod_big_int</code> (see above).<br>
</div>
<pre><span class="keyword">val</span> <a name="VALmod_big_int"></a>mod_big_int : <code class="type"><a href="Big_int.html#TYPEbig_int">big_int</a> -> <a href="Big_int.html#TYPEbig_int">big_int</a> -> <a href="Big_int.html#TYPEbig_int">big_int</a></code></pre><div class="info">
Euclidean modulus of two big integers.
This is the second result <code class="code">r</code> of <code class="code">quomod_big_int</code> (see above).<br>
</div>
<pre><span class="keyword">val</span> <a name="VALgcd_big_int"></a>gcd_big_int : <code class="type"><a href="Big_int.html#TYPEbig_int">big_int</a> -> <a href="Big_int.html#TYPEbig_int">big_int</a> -> <a href="Big_int.html#TYPEbig_int">big_int</a></code></pre><div class="info">
Greatest common divisor of two big integers.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALpower_int_positive_int"></a>power_int_positive_int : <code class="type">int -> int -> <a href="Big_int.html#TYPEbig_int">big_int</a></code></pre><pre><span class="keyword">val</span> <a name="VALpower_big_int_positive_int"></a>power_big_int_positive_int : <code class="type"><a href="Big_int.html#TYPEbig_int">big_int</a> -> int -> <a href="Big_int.html#TYPEbig_int">big_int</a></code></pre><pre><span class="keyword">val</span> <a name="VALpower_int_positive_big_int"></a>power_int_positive_big_int : <code class="type">int -> <a href="Big_int.html#TYPEbig_int">big_int</a> -> <a href="Big_int.html#TYPEbig_int">big_int</a></code></pre><pre><span class="keyword">val</span> <a name="VALpower_big_int_positive_big_int"></a>power_big_int_positive_big_int : <code class="type"><a href="Big_int.html#TYPEbig_int">big_int</a> -> <a href="Big_int.html#TYPEbig_int">big_int</a> -> <a href="Big_int.html#TYPEbig_int">big_int</a></code></pre><div class="info">
Exponentiation functions. Return the big integer
representing the first argument <code class="code">a</code> raised to the power <code class="code">b</code>
(the second argument). Depending
on the function, <code class="code">a</code> and <code class="code">b</code> can be either small integers
or big integers. Raise <code class="code"><span class="constructor">Invalid_argument</span></code> if <code class="code">b</code> is negative.<br>
</div>
<br>
<a name="6_Comparisonsandtests"></a>
<h6>Comparisons and tests</h6><br>
<pre><span class="keyword">val</span> <a name="VALsign_big_int"></a>sign_big_int : <code class="type"><a href="Big_int.html#TYPEbig_int">big_int</a> -> int</code></pre><div class="info">
Return <code class="code">0</code> if the given big integer is zero,
<code class="code">1</code> if it is positive, and <code class="code">-1</code> if it is negative.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALcompare_big_int"></a>compare_big_int : <code class="type"><a href="Big_int.html#TYPEbig_int">big_int</a> -> <a href="Big_int.html#TYPEbig_int">big_int</a> -> int</code></pre><div class="info">
<code class="code">compare_big_int a b</code> returns <code class="code">0</code> if <code class="code">a</code> and <code class="code">b</code> are equal,
<code class="code">1</code> if <code class="code">a</code> is greater than <code class="code">b</code>, and <code class="code">-1</code> if <code class="code">a</code> is smaller
than <code class="code">b</code>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALeq_big_int"></a>eq_big_int : <code class="type"><a href="Big_int.html#TYPEbig_int">big_int</a> -> <a href="Big_int.html#TYPEbig_int">big_int</a> -> bool</code></pre><pre><span class="keyword">val</span> <a name="VALle_big_int"></a>le_big_int : <code class="type"><a href="Big_int.html#TYPEbig_int">big_int</a> -> <a href="Big_int.html#TYPEbig_int">big_int</a> -> bool</code></pre><pre><span class="keyword">val</span> <a name="VALge_big_int"></a>ge_big_int : <code class="type"><a href="Big_int.html#TYPEbig_int">big_int</a> -> <a href="Big_int.html#TYPEbig_int">big_int</a> -> bool</code></pre><pre><span class="keyword">val</span> <a name="VALlt_big_int"></a>lt_big_int : <code class="type"><a href="Big_int.html#TYPEbig_int">big_int</a> -> <a href="Big_int.html#TYPEbig_int">big_int</a> -> bool</code></pre><pre><span class="keyword">val</span> <a name="VALgt_big_int"></a>gt_big_int : <code class="type"><a href="Big_int.html#TYPEbig_int">big_int</a> -> <a href="Big_int.html#TYPEbig_int">big_int</a> -> bool</code></pre><div class="info">
Usual boolean comparisons between two big integers.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALmax_big_int"></a>max_big_int : <code class="type"><a href="Big_int.html#TYPEbig_int">big_int</a> -> <a href="Big_int.html#TYPEbig_int">big_int</a> -> <a href="Big_int.html#TYPEbig_int">big_int</a></code></pre><div class="info">
Return the greater of its two arguments.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALmin_big_int"></a>min_big_int : <code class="type"><a href="Big_int.html#TYPEbig_int">big_int</a> -> <a href="Big_int.html#TYPEbig_int">big_int</a> -> <a href="Big_int.html#TYPEbig_int">big_int</a></code></pre><div class="info">
Return the smaller of its two arguments.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALnum_digits_big_int"></a>num_digits_big_int : <code class="type"><a href="Big_int.html#TYPEbig_int">big_int</a> -> int</code></pre><div class="info">
Return the number of machine words used to store the
given big integer.<br>
</div>
<br>
<a name="6_Conversionstoandfromstrings"></a>
<h6>Conversions to and from strings</h6><br>
<pre><span class="keyword">val</span> <a name="VALstring_of_big_int"></a>string_of_big_int : <code class="type"><a href="Big_int.html#TYPEbig_int">big_int</a> -> string</code></pre><div class="info">
Return the string representation of the given big integer,
in decimal (base 10).<br>
</div>
<pre><span class="keyword">val</span> <a name="VALbig_int_of_string"></a>big_int_of_string : <code class="type">string -> <a href="Big_int.html#TYPEbig_int">big_int</a></code></pre><div class="info">
Convert a string to a big integer, in decimal.
The string consists of an optional <code class="code">-</code> or <code class="code">+</code> sign,
followed by one or several decimal digits.<br>
</div>
<br>
<a name="6_Conversionstoandfromothernumericaltypes"></a>
<h6>Conversions to and from other numerical types</h6><br>
<pre><span class="keyword">val</span> <a name="VALbig_int_of_int"></a>big_int_of_int : <code class="type">int -> <a href="Big_int.html#TYPEbig_int">big_int</a></code></pre><div class="info">
Convert a small integer to a big integer.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALis_int_big_int"></a>is_int_big_int : <code class="type"><a href="Big_int.html#TYPEbig_int">big_int</a> -> bool</code></pre><div class="info">
Test whether the given big integer is small enough to
be representable as a small integer (type <code class="code">int</code>)
without loss of precision. On a 32-bit platform,
<code class="code">is_int_big_int a</code> returns <code class="code"><span class="keyword">true</span></code> if and only if
<code class="code">a</code> is between 2<sup class="superscript">30</sup> and 2<sup class="superscript">30</sup>-1. On a 64-bit platform,
<code class="code">is_int_big_int a</code> returns <code class="code"><span class="keyword">true</span></code> if and only if
<code class="code">a</code> is between -2<sup class="superscript">62</sup> and 2<sup class="superscript">62</sup>-1.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALint_of_big_int"></a>int_of_big_int : <code class="type"><a href="Big_int.html#TYPEbig_int">big_int</a> -> int</code></pre><div class="info">
Convert a big integer to a small integer (type <code class="code">int</code>).
Raises <code class="code"><span class="constructor">Failure</span> <span class="string">"int_of_big_int"</span></code> if the big integer
is not representable as a small integer.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALfloat_of_big_int"></a>float_of_big_int : <code class="type"><a href="Big_int.html#TYPEbig_int">big_int</a> -> float</code></pre><div class="info">
Returns a floating-point number approximating the
given big integer.<br>
</div>
</body></html>
|