ocaml-containers/3.0/containers/CCFloat/index.html
Simon Cruanes 2fa8e5f507 fix doc
2020-08-04 09:49:29 -04:00

2 lines
No EOL
18 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="generator" content="odoc 1.5.1"/><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><code>nan</code> is Not a Number (NaN). 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><code>max_value</code> is 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><code>min_value</code> is 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><code>max_finite_value</code> is the largest finite float value. 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><code>epsilon</code> is 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-pi"><a href="#val-pi" class="anchor"></a><code><span class="keyword">val</span> pi : <a href="index.html#type-t">t</a></code></dt><dd><p><code>pi</code> is the constant pi. The ratio of a circumference to its diameter.</p><dl><dt>since</dt><dd>3.0</dd></dl></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><code>add x y</code> is equal to <code>x +. y</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><code>sub x y</code> is equal to <code>x -. y</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><code>neg x</code> is equal to <code>~-. x</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><code>abs x</code> is the absolute value of the floating-point number <code>x</code>. 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><code>scale x y</code> is equal to <code>x *. y</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><dd><p><code>min x y</code> returns the min of the two given values <code>x</code> and <code>y</code>.</p></dd></dl><dl><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><dd><p><code>max x y</code> returns the max of the two given values <code>x</code> and <code>y</code>.</p></dd></dl><dl><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><dd><p><code>equal x y</code> is <code>true</code> if <code>x</code> and <code>y</code> are the same.</p></dd></dl><dl><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><dd><p><code>compare x y</code> is <span class="xref-unresolved" title="unresolved reference to &quot;Stdlib.compare x y&quot;"><code>Stdlib</code>.compare x y</span>.</p></dd></dl><dl><dt class="spec type" id="type-printer"><a href="#type-printer" class="anchor"></a><code><span class="keyword">type</span> <span>'a printer</span></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> <span>'a random_gen</span></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 : <span><a href="index.html#type-t">t</a> <a href="index.html#type-printer">printer</a></span></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> <span><a href="index.html#type-t">t</a> <a href="index.html#type-random_gen">random_gen</a></span></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 : <span><a href="index.html#type-t">t</a> <a href="index.html#type-random_gen">random_gen</a></span></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> <span><a href="index.html#type-t">t</a> <a href="index.html#type-random_gen">random_gen</a></span></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 x</code> returns the closest integer value, either above or below. For <code>n + 0.5</code>, <code>round</code> returns <code>n</code>.</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_opt"><a href="#val-of_string_opt" class="anchor"></a><code><span class="keyword">val</span> of_string_opt : string <span>&#45;&gt;</span> <span><a href="index.html#type-t">t</a> option</span></code></dt><dd><dl><dt>since</dt><dd>3.0</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 : <span>epsilon:<a href="index.html#type-t">t</a></span> <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><code>classify x</code> returns the class of the given floating-point number <code>x</code>: 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>