003 File Manager
Current Path:
/usr/local/share/doc/mpdecimal/libmpdec
usr
/
local
/
share
/
doc
/
mpdecimal
/
libmpdec
/
📁
..
📄
README.txt
(88 B)
📁
_static
📄
arithmetic.html
(109.46 KB)
📄
assign-convert.html
(56.83 KB)
📄
attributes.html
(24.85 KB)
📄
context.html
(37.84 KB)
📄
decimals.html
(8.45 KB)
📄
functions.html
(58.37 KB)
📄
index.html
(16.95 KB)
📄
memory.html
(15.59 KB)
📄
objects.inv
(1.83 KB)
📄
search.html
(2.76 KB)
📄
searchindex.js
(30.97 KB)
📄
various.html
(40.5 KB)
Editing: decimals.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="X-UA-Compatible" content="IE=Edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta content="index,follow" name="robots" /> <meta content="libmpdec documentation" name="description" /> <title>Decimals — mpdecimal 2.5.1 documentation</title> <link rel="stylesheet" href="_static/mpdecimal-doc.css" type="text/css" /> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script> <script src="_static/jquery.js"></script> <script src="_static/underscore.js"></script> <script src="_static/doctools.js"></script> <script src="_static/language_data.js"></script> <link rel="search" title="Search" href="search.html" /> <link rel="next" title="Assignment, Conversions, I/O" href="assign-convert.html" /> <link rel="prev" title="Context" href="context.html" /> </head><body> <div class="related" role="navigation" aria-label="related navigation"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="assign-convert.html" title="Assignment, Conversions, I/O" accesskey="N">next</a></li> <li class="right" > <a href="context.html" title="Context" accesskey="P">previous</a> |</li> <li><a href="http://www.bytereef.org/mpdecimal/index.html">project home</a></li> </ul> </div> <div class="sphinxsidebar" role="navigation" aria-label="main navigation"> <div class="sphinxsidebarwrapper"> <h3><a href="index.html">Table of Contents</a></h3> <ul> <li><a class="reference internal" href="#">Decimals</a><ul> <li><a class="reference internal" href="#data-type">Data Type</a></li> <li><a class="reference internal" href="#allocation-functions">Allocation Functions</a></li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="context.html" title="previous chapter">Context</a></p> <h4>Next topic</h4> <p class="topless"><a href="assign-convert.html" title="next chapter">Assignment, Conversions, I/O</a></p> <div id="searchbox" style="display: none" role="search"> <h3 id="searchlabel">Quick search</h3> <div class="searchformwrapper"> <form class="search" action="search.html" method="get"> <input type="text" name="q" aria-labelledby="searchlabel" /> <input type="submit" value="Go" /> </form> </div> </div> <script>$('#searchbox').show(0);</script> </div> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body" role="main"> <div class="section" id="decimals"> <h1>Decimals</h1> <div class="section" id="data-type"> <h2>Data Type</h2> <p>The decimal data type is called <code class="xref c c-macro docutils literal notranslate"><span class="pre">mpd_t</span></code>, which is short for <em>multi precision decimal</em>.</p> <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#include</span> <span class="cpf"><mpdecimal.h></span><span class="cp"></span> <span class="k">typedef</span> <span class="k">struct</span> <span class="nc">mpd_t</span> <span class="p">{</span> <span class="kt">uint8_t</span> <span class="n">flags</span><span class="p">;</span> <span class="c1">// [memory flags] | [specials] | sign</span> <span class="n">mpd_ssize_t</span> <span class="n">exp</span><span class="p">;</span> <span class="c1">// exponent</span> <span class="n">mpd_ssize_t</span> <span class="n">digits</span><span class="p">;</span> <span class="c1">// number of decimal digits</span> <span class="n">mpd_ssize_t</span> <span class="n">len</span><span class="p">;</span> <span class="c1">// number of words in use</span> <span class="n">mpd_ssize_t</span> <span class="n">alloc</span><span class="p">;</span> <span class="c1">// number of allocated words</span> <span class="n">mpd_uint_t</span> <span class="o">*</span><span class="n">data</span><span class="p">;</span> <span class="c1">// words</span> <span class="p">}</span> <span class="n">mpd_t</span><span class="p">;</span> </pre></div> </div> <p>The flags contain two types of information: The lowest bit is the sign of the decimal. The following three bits determine whether the decimal is Infinity, NaN or sNaN. The upper four bits carry the information how the storage was allocated. The normal case is that both the struct and the data have been dynamically allocated by <code class="xref c c-func docutils literal notranslate"><span class="pre">mpd_new</span></code>. More on this in the section <a class="reference internal" href="memory.html#advanced-memory-handling"><span class="std std-ref">Advanced Memory Handling</span></a>.</p> </div> <div class="section" id="allocation-functions"> <h2>Allocation Functions</h2> <span class="target" id="std:topic-mpd_qnew"></span><div class="highlight-c notranslate" id="std:topic-mpd_new"><div class="highlight"><pre><span></span><span class="n">mpd_t</span> <span class="o">*</span><span class="nf">mpd_qnew</span><span class="p">(</span><span class="kt">void</span><span class="p">);</span> <span class="n">mpd_t</span> <span class="o">*</span><span class="nf">mpd_new</span><span class="p">(</span><span class="n">mpd_context_t</span> <span class="o">*</span><span class="n">ctx</span><span class="p">);</span> </pre></div> </div> <p><code class="xref c c-func docutils literal notranslate"><span class="pre">mpd_qnew</span></code> attempts to allocate a dynamic decimal with <code class="xref c c-macro docutils literal notranslate"><span class="pre">MPD_MINALLOC</span></code> words reserved for the coefficient. If successful, the return value is the new pointer, <code class="xref c c-macro docutils literal notranslate"><span class="pre">NULL</span></code> otherwise. <code class="xref c c-func docutils literal notranslate"><span class="pre">mpd_new</span></code> is the same, but raises the <code class="xref c c-macro docutils literal notranslate"><span class="pre">MPD_Malloc_error</span></code> exception on failure.</p> <div class="highlight-c notranslate" id="std:topic-mpd_qnew_size"><div class="highlight"><pre><span></span><span class="n">mpd_t</span> <span class="o">*</span><span class="nf">mpd_qnew_size</span><span class="p">(</span><span class="n">mpd_ssize_t</span> <span class="n">size</span><span class="p">);</span> </pre></div> </div> <p>Same as <code class="xref c c-func docutils literal notranslate"><span class="pre">mpd_qnew</span></code>, but the <em>size</em> argument indicates that <em>size</em> words should be allocated for the coefficient rather than <code class="xref c c-macro docutils literal notranslate"><span class="pre">MPD_MINALLOC</span></code> words.</p> <div class="highlight-c notranslate" id="std:topic-mpd_del"><div class="highlight"><pre><span></span><span class="kt">void</span> <span class="nf">mpd_del</span><span class="p">(</span><span class="n">mpd_t</span> <span class="o">*</span><span class="n">dec</span><span class="p">);</span> </pre></div> </div> <p><code class="xref c c-func docutils literal notranslate"><span class="pre">mpd_del</span></code> frees all storage allocated for a decimal. The function may also be called with a completely or partly static decimal as an argument, see <a class="reference internal" href="memory.html#advanced-memory-handling"><span class="std std-ref">Advanced Memory Handling</span></a>.</p> </div> </div> </div> </div> </div> <div class="clearer"></div> </div> <div class="related" role="navigation" aria-label="related navigation"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="assign-convert.html" title="Assignment, Conversions, I/O" >next</a></li> <li class="right" > <a href="context.html" title="Context" >previous</a> |</li> <li><a href="http://www.bytereef.org/mpdecimal/index.html">project home</a></li> </ul> </div> <div class="footer" role="contentinfo"> © Copyright 2010-2020, Stefan Krah. Created using <a href="http://sphinx-doc.org/">Sphinx</a> 2.4.4. </div> </body> </html>
Upload File
Create Folder