<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <link rel="stylesheet" href="style.css" type="text/css"> <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type"> <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="CamlinternalLazy" rel="Chapter" href="CamlinternalLazy.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="Tk" rel="Chapter" href="Tk.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="VALbig_int_of_int32"></a>big_int_of_int32 : <code class="type">int32 -> <a href="Big_int.html#TYPEbig_int">big_int</a></code></pre><div class="info"> Convert a 32-bit integer to a big integer.<br> </div> <pre><span class="keyword">val</span> <a name="VALbig_int_of_nativeint"></a>big_int_of_nativeint : <code class="type">nativeint -> <a href="Big_int.html#TYPEbig_int">big_int</a></code></pre><div class="info"> Convert a native integer to a big integer.<br> </div> <pre><span class="keyword">val</span> <a name="VALbig_int_of_int64"></a>big_int_of_int64 : <code class="type">int64 -> <a href="Big_int.html#TYPEbig_int">big_int</a></code></pre><div class="info"> Convert a 64-bit integer to a big integer.<br> </div> <pre><span class="keyword">val</span> <a name="VALint32_of_big_int"></a>int32_of_big_int : <code class="type"><a href="Big_int.html#TYPEbig_int">big_int</a> -> int32</code></pre><div class="info"> Convert a big integer to a 32-bit integer. Raises <code class="code"><span class="constructor">Failure</span></code> if the big integer is outside the range <code class="code">[-2{^31}, 2{^31}-1]</code>.<br> </div> <pre><span class="keyword">val</span> <a name="VALnativeint_of_big_int"></a>nativeint_of_big_int : <code class="type"><a href="Big_int.html#TYPEbig_int">big_int</a> -> nativeint</code></pre><div class="info"> Convert a big integer to a native integer. Raises <code class="code"><span class="constructor">Failure</span></code> if the big integer is outside the range <code class="code">[<span class="constructor">Nativeint</span>.min_int, <span class="constructor">Nativeint</span>.max_int]</code>.<br> </div> <pre><span class="keyword">val</span> <a name="VALint64_of_big_int"></a>int64_of_big_int : <code class="type"><a href="Big_int.html#TYPEbig_int">big_int</a> -> int64</code></pre><div class="info"> Convert a big integer to a 64-bit integer. Raises <code class="code"><span class="constructor">Failure</span></code> if the big integer is outside the range <code class="code">[-2{^63}, 2{^63}-1]</code>.<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>