ocaml-containers/2.6/containers/CCFloat/index.html
2019-06-18 23:01:25 -05:00

2 lines
No EOL
17 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>CCFloat (containers.CCFloat)</title><link rel="stylesheet" href="../../odoc.css"/><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div class="content"><header><nav><a href="../index.html">Up</a> <a href="../index.html">containers</a> &#x00BB; CCFloat</nav><h1>Module <code>CCFloat</code></h1><h2 id="basic-operations-on-floating-point-numbers"><a href="#basic-operations-on-floating-point-numbers" class="anchor"></a>Basic operations on floating-point numbers</h2><dl><dt>since</dt><dd>0.6.1</dd></dl><nav class="toc"><ul><li><a href="#infix-operators">Infix Operators</a></li></ul></nav></header><dl><dt class="spec type" id="type-t"><a href="#type-t" class="anchor"></a><code><span class="keyword">type</span> t</code><code> = float</code></dt><dt class="spec type" id="type-fpclass"><a href="#type-fpclass" class="anchor"></a><code><span class="keyword">type</span> fpclass</code><code> = <a href="../CCShims_/index.html#module-Stdlib">CCShims_.Stdlib</a>.fpclass</code><code> = </code><table class="variant"><tr id="type-fpclass.FP_normal" class="anchored"><td class="def constructor"><a href="#type-fpclass.FP_normal" class="anchor"></a><code>| </code><code><span class="constructor">FP_normal</span></code></td></tr><tr id="type-fpclass.FP_subnormal" class="anchored"><td class="def constructor"><a href="#type-fpclass.FP_subnormal" class="anchor"></a><code>| </code><code><span class="constructor">FP_subnormal</span></code></td></tr><tr id="type-fpclass.FP_zero" class="anchored"><td class="def constructor"><a href="#type-fpclass.FP_zero" class="anchor"></a><code>| </code><code><span class="constructor">FP_zero</span></code></td></tr><tr id="type-fpclass.FP_infinite" class="anchored"><td class="def constructor"><a href="#type-fpclass.FP_infinite" class="anchor"></a><code>| </code><code><span class="constructor">FP_infinite</span></code></td></tr><tr id="type-fpclass.FP_nan" class="anchored"><td class="def constructor"><a href="#type-fpclass.FP_nan" class="anchor"></a><code>| </code><code><span class="constructor">FP_nan</span></code></td></tr></table></dt></dl><dl><dt class="spec value" id="val-nan"><a href="#val-nan" class="anchor"></a><code><span class="keyword">val</span> nan : <a href="index.html#type-t">t</a></code></dt><dd><p>Equal to <span class="xref-unresolved" title="unresolved reference to &quot;Stdlib.nan&quot;"><code>Stdlib</code>.nan</span>.</p></dd></dl><dl><dt class="spec value" id="val-max_value"><a href="#val-max_value" class="anchor"></a><code><span class="keyword">val</span> max_value : <a href="index.html#type-t">t</a></code></dt><dd><p>Positive infinity. Equal to <span class="xref-unresolved" title="unresolved reference to &quot;Stdlib.infinity&quot;"><code>Stdlib</code>.infinity</span>.</p></dd></dl><dl><dt class="spec value" id="val-min_value"><a href="#val-min_value" class="anchor"></a><code><span class="keyword">val</span> min_value : <a href="index.html#type-t">t</a></code></dt><dd><p>Negative infinity. Equal to <span class="xref-unresolved" title="unresolved reference to &quot;Stdlib.neg_infinity&quot;"><code>Stdlib</code>.neg_infinity</span>.</p></dd></dl><dl><dt class="spec value" id="val-max_finite_value"><a href="#val-max_finite_value" class="anchor"></a><code><span class="keyword">val</span> max_finite_value : <a href="index.html#type-t">t</a></code></dt><dd><p>Equal to <span class="xref-unresolved" title="unresolved reference to &quot;Stdlib.max_float&quot;"><code>Stdlib</code>.max_float</span>.</p></dd></dl><dl><dt class="spec value" id="val-epsilon"><a href="#val-epsilon" class="anchor"></a><code><span class="keyword">val</span> epsilon : <a href="index.html#type-t">t</a></code></dt><dd><p>The smallest positive float x such that <code>1.0 +. x &lt;&gt; 1.0</code>. Equal to <span class="xref-unresolved" title="unresolved reference to &quot;Stdlib.epsilon_float&quot;"><code>Stdlib</code>.epsilon_float</span>.</p></dd></dl><dl><dt class="spec value" id="val-is_nan"><a href="#val-is_nan" class="anchor"></a><code><span class="keyword">val</span> is_nan : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> bool</code></dt><dd><p><code>is_nan f</code> returns <code>true</code> if f is NaN, <code>false</code> otherwise.</p></dd></dl><dl><dt class="spec value" id="val-add"><a href="#val-add" class="anchor"></a><code><span class="keyword">val</span> add : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>Equal to <code>(+.)</code>.</p></dd></dl><dl><dt class="spec value" id="val-sub"><a href="#val-sub" class="anchor"></a><code><span class="keyword">val</span> sub : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>Equal to <code>(-.)</code>.</p></dd></dl><dl><dt class="spec value" id="val-neg"><a href="#val-neg" class="anchor"></a><code><span class="keyword">val</span> neg : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>Equal to <code>(~-.)</code>.</p></dd></dl><dl><dt class="spec value" id="val-abs"><a href="#val-abs" class="anchor"></a><code><span class="keyword">val</span> abs : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>The absolute value of a floating-point number. Equal to <span class="xref-unresolved" title="unresolved reference to &quot;Stdlib.abs_float&quot;"><code>Stdlib</code>.abs_float</span>.</p></dd></dl><dl><dt class="spec value" id="val-scale"><a href="#val-scale" class="anchor"></a><code><span class="keyword">val</span> scale : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>Equal to <code>( *. )</code>.</p></dd></dl><dl><dt class="spec value" id="val-min"><a href="#val-min" class="anchor"></a><code><span class="keyword">val</span> min : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dt class="spec value" id="val-max"><a href="#val-max" class="anchor"></a><code><span class="keyword">val</span> max : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dt class="spec value" id="val-equal"><a href="#val-equal" class="anchor"></a><code><span class="keyword">val</span> equal : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> bool</code></dt><dt class="spec value" id="val-compare"><a href="#val-compare" class="anchor"></a><code><span class="keyword">val</span> compare : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> int</code></dt></dl><dl><dt class="spec type" id="type-printer"><a href="#type-printer" class="anchor"></a><code><span class="keyword">type</span> 'a printer</code><code> = Stdlib.Format.formatter <span>&#45;&gt;</span> <span class="type-var">'a</span> <span>&#45;&gt;</span> unit</code></dt><dt class="spec type" id="type-random_gen"><a href="#type-random_gen" class="anchor"></a><code><span class="keyword">type</span> 'a random_gen</code><code> = Stdlib.Random.State.t <span>&#45;&gt;</span> <span class="type-var">'a</span></code></dt></dl><dl><dt class="spec value" id="val-pp"><a href="#val-pp" class="anchor"></a><code><span class="keyword">val</span> pp : <a href="index.html#type-t">t</a> <a href="index.html#type-printer">printer</a></code></dt><dt class="spec value" id="val-hash"><a href="#val-hash" class="anchor"></a><code><span class="keyword">val</span> hash : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> int</code></dt><dt class="spec value" id="val-random"><a href="#val-random" class="anchor"></a><code><span class="keyword">val</span> random : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <a href="index.html#type-random_gen">random_gen</a></code></dt><dt class="spec value" id="val-random_small"><a href="#val-random_small" class="anchor"></a><code><span class="keyword">val</span> random_small : <a href="index.html#type-t">t</a> <a href="index.html#type-random_gen">random_gen</a></code></dt><dt class="spec value" id="val-random_range"><a href="#val-random_range" class="anchor"></a><code><span class="keyword">val</span> random_range : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <a href="index.html#type-random_gen">random_gen</a></code></dt><dt class="spec value" id="val-fsign"><a href="#val-fsign" class="anchor"></a><code><span class="keyword">val</span> fsign : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p><code>fsign x</code> is one of <code>-1., -0., +0., +1.</code>, or <code>nan</code> if <code>x</code> is NaN.</p><dl><dt>since</dt><dd>0.7</dd></dl></dd></dl><dl><dt class="spec value" id="val-round"><a href="#val-round" class="anchor"></a><code><span class="keyword">val</span> round : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p><code>round f</code> returns the closest integer value, either above or below.</p><dl><dt>since</dt><dd>0.20</dd></dl></dd></dl><dl><dt class="spec exception" id="exception-TrapNaN"><a href="#exception-TrapNaN" class="anchor"></a><code><span class="keyword">exception</span> </code><code><span class="exception">TrapNaN</span> <span class="keyword">of</span> string</code></dt></dl><dl><dt class="spec value" id="val-sign_exn"><a href="#val-sign_exn" class="anchor"></a><code><span class="keyword">val</span> sign_exn : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> int</code></dt><dd><p><code>sign_exn x</code> will return the sign of <code>x</code> as <code>1, 0</code> or <code>-1</code>, or raise an exception <code>TrapNaN</code> if <code>x</code> is NaN. Note that infinities have defined signs in OCaml.</p><dl><dt>since</dt><dd>0.7</dd></dl></dd></dl><dl><dt class="spec value" id="val-to_int"><a href="#val-to_int" class="anchor"></a><code><span class="keyword">val</span> to_int : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> int</code></dt><dd><p>Alias to <code>int_of_float</code>. Unspecified if outside of the range of integers.</p></dd></dl><dl><dt class="spec value" id="val-of_int"><a href="#val-of_int" class="anchor"></a><code><span class="keyword">val</span> of_int : int <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>Alias to <code>float_of_int</code>.</p></dd></dl><dl><dt class="spec value" id="val-to_string"><a href="#val-to_string" class="anchor"></a><code><span class="keyword">val</span> to_string : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> string</code></dt><dt class="spec value" id="val-of_string_exn"><a href="#val-of_string_exn" class="anchor"></a><code><span class="keyword">val</span> of_string_exn : string <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>Alias to <code>float_of_string</code>.</p><dl><dt>raises Failure</dt><dd><p>in case of failure.</p></dd></dl><dl><dt>since</dt><dd>1.2</dd></dl></dd></dl><dl><dt class="spec value" id="val-of_string"><a href="#val-of_string" class="anchor"></a><code><span class="keyword">val</span> of_string : string <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>Alias to <code>float_of_string</code>.</p><dl><dt>deprecated</dt><dd><p>since 1.2, use <a href="index.html#val-of_string_exn"><code>of_string_exn</code></a> instead.</p></dd></dl><dl><dt>raises Failure</dt><dd><p>in case of failure.</p></dd></dl></dd></dl><dl><dt class="spec value" id="val-equal_precision"><a href="#val-equal_precision" class="anchor"></a><code><span class="keyword">val</span> equal_precision : epsilon:<a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> bool</code></dt><dd><p>Equality with allowed error up to a non negative epsilon value.</p></dd></dl><dl><dt class="spec value" id="val-classify"><a href="#val-classify" class="anchor"></a><code><span class="keyword">val</span> classify : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-fpclass">fpclass</a></code></dt><dd><p>Return the class of the given floating-point number: normal, subnormal, zero, infinite or nan (not a number).</p></dd></dl><section><header><h3 id="infix-operators"><a href="#infix-operators" class="anchor"></a>Infix Operators</h3><dl><dt>since</dt><dd>0.17</dd></dl></header><div class="spec module" id="module-Infix"><a href="#module-Infix" class="anchor"></a><code><span class="keyword">module</span> <a href="Infix/index.html">Infix</a> : <span class="keyword">sig</span> ... <span class="keyword">end</span></code></div><div><div class="spec include"><div class="doc"><details open="open"><summary><span class="def"><code><span class="keyword">include</span> <span class="keyword">module</span> <span class="keyword">type</span> <span class="keyword">of</span> <a href="index.html#module-Infix">Infix</a></code></span></summary><dl><dt class="spec value" id="val-(=)"><a href="#val-(=)" class="anchor"></a><code><span class="keyword">val</span> (=) : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> bool</code></dt><dd><dl><dt>since</dt><dd>0.17</dd></dl></dd></dl><dl><dt class="spec value" id="val-(&lt;&gt;)"><a href="#val-(&lt;&gt;)" class="anchor"></a><code><span class="keyword">val</span> (&lt;&gt;) : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> bool</code></dt><dd><dl><dt>since</dt><dd>0.17</dd></dl></dd></dl><dl><dt class="spec value" id="val-(&lt;)"><a href="#val-(&lt;)" class="anchor"></a><code><span class="keyword">val</span> (&lt;) : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> bool</code></dt><dd><dl><dt>since</dt><dd>0.17</dd></dl></dd></dl><dl><dt class="spec value" id="val-(&gt;)"><a href="#val-(&gt;)" class="anchor"></a><code><span class="keyword">val</span> (&gt;) : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> bool</code></dt><dd><dl><dt>since</dt><dd>0.17</dd></dl></dd></dl><dl><dt class="spec value" id="val-(&lt;=)"><a href="#val-(&lt;=)" class="anchor"></a><code><span class="keyword">val</span> (&lt;=) : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> bool</code></dt><dd><dl><dt>since</dt><dd>0.17</dd></dl></dd></dl><dl><dt class="spec value" id="val-(&gt;=)"><a href="#val-(&gt;=)" class="anchor"></a><code><span class="keyword">val</span> (&gt;=) : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> bool</code></dt><dd><dl><dt>since</dt><dd>0.17</dd></dl></dd></dl><dl><dt class="spec value" id="val-(+)"><a href="#val-(+)" class="anchor"></a><code><span class="keyword">val</span> (+) : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>Addition.</p><dl><dt>since</dt><dd>2.1</dd></dl></dd></dl><dl><dt class="spec value" id="val-(-)"><a href="#val-(-)" class="anchor"></a><code><span class="keyword">val</span> (-) : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>Subtraction.</p><dl><dt>since</dt><dd>2.1</dd></dl></dd></dl><dl><dt class="spec value" id="val-(~-)"><a href="#val-(~-)" class="anchor"></a><code><span class="keyword">val</span> (~-) : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>Unary negation.</p><dl><dt>since</dt><dd>2.1</dd></dl></dd></dl><dl><dt class="spec value" id="val-(*)"><a href="#val-(*)" class="anchor"></a><code><span class="keyword">val</span> (*) : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>Multiplication.</p><dl><dt>since</dt><dd>2.1</dd></dl></dd></dl><dl><dt class="spec value" id="val-(/)"><a href="#val-(/)" class="anchor"></a><code><span class="keyword">val</span> (/) : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>Division.</p><dl><dt>since</dt><dd>2.1</dd></dl></dd></dl></details></div></div></div></section></div></body></html>