/usr/share/doc/libmpdec-doc/various.html is in libmpdec-doc 2.4.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 | <!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="Content-Type" content="text/html; charset=utf-8" />
<meta content="index,follow" name="robots" />
<meta content="libmpdec documentation" name="description" />
<title>Various Functions — mpdecimal 2.4.2 documentation</title>
<link rel="stylesheet" href="_static/mpdecimal-doc.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '2.4.2',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: false
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="mpdecimal 2.4.2 documentation" href="index.html" />
<link rel="next" title="Advanced Memory Handling" href="memory.html" />
<link rel="prev" title="Arithmetic Functions" href="arithmetic.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="memory.html" title="Advanced Memory Handling"
accesskey="N">next</a></li>
<li class="right" >
<a href="arithmetic.html" title="Arithmetic Functions"
accesskey="P">previous</a> |</li>
<li><a href="http://www.bytereef.org/mpdecimal/index.html">project home</a></li>
</ul>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Various Functions</a><ul>
<li><a class="reference internal" href="#applying-the-context">Applying the Context</a><ul>
<li><a class="reference internal" href="#finalize">finalize</a></li>
</ul>
</li>
<li><a class="reference internal" href="#nan-handling">NaN Handling</a><ul>
<li><a class="reference internal" href="#check-nan">check-nan</a></li>
<li><a class="reference internal" href="#check-nans">check-nans</a></li>
</ul>
</li>
<li><a class="reference internal" href="#shifting-and-rotating">Shifting and Rotating</a><ul>
<li><a class="reference internal" href="#shift">shift</a></li>
<li><a class="reference internal" href="#shiftn">shiftn</a></li>
<li><a class="reference internal" href="#shiftl">shiftl</a></li>
<li><a class="reference internal" href="#shiftr">shiftr</a></li>
<li><a class="reference internal" href="#shiftr-inplace">shiftr-inplace</a></li>
<li><a class="reference internal" href="#rotate">rotate</a></li>
</ul>
</li>
<li><a class="reference internal" href="#logical-operations">Logical Operations</a><ul>
<li><a class="reference internal" href="#and">and</a></li>
<li><a class="reference internal" href="#or">or</a></li>
<li><a class="reference internal" href="#xor">xor</a></li>
<li><a class="reference internal" href="#invert">invert</a></li>
</ul>
</li>
<li><a class="reference internal" href="#base-conversions">Base Conversions</a><ul>
<li><a class="reference internal" href="#importing">Importing</a></li>
<li><a class="reference internal" href="#exporting">Exporting</a></li>
</ul>
</li>
<li><a class="reference internal" href="#required-functions">Required Functions</a></li>
<li><a class="reference internal" href="#library-version">Library version</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="arithmetic.html"
title="previous chapter">Arithmetic Functions</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="memory.html"
title="next chapter">Advanced Memory Handling</a></p>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="various-functions">
<h1>Various Functions</h1>
<div class="section" id="applying-the-context">
<h2>Applying the Context</h2>
<div class="section" id="finalize">
<h3>finalize</h3>
<span class="target" id="std:topic-mpd_qfinalize"></span><div class="highlight-c" id="std:topic-mpd_finalize"><div class="highlight"><pre><span class="kt">void</span> <span class="nf">mpd_qfinalize</span><span class="p">(</span><span class="kt">mpd_t</span> <span class="o">*</span><span class="n">result</span><span class="p">,</span> <span class="k">const</span> <span class="kt">mpd_context_t</span> <span class="o">*</span><span class="n">ctx</span><span class="p">,</span>
<span class="kt">uint32_t</span> <span class="o">*</span><span class="n">status</span><span class="p">);</span>
<span class="kt">void</span> <span class="nf">mpd_finalize</span><span class="p">(</span><span class="kt">mpd_t</span> <span class="o">*</span><span class="n">result</span><span class="p">,</span> <span class="kt">mpd_context_t</span> <span class="o">*</span><span class="n">ctx</span><span class="p">);</span>
</pre></div>
</div>
<p>Apply <em>ctx</em> to <em>result</em>. This function performs checks the exponent limits
and performs rounding. The following conditions can occur:</p>
<p><tt class="xref c c-macro docutils literal"><span class="pre">MPD_Clamped</span></tt>, <tt class="xref c c-macro docutils literal"><span class="pre">MPD_Inexact</span></tt>, <tt class="xref c c-macro docutils literal"><span class="pre">MPD_Overflow</span></tt>,
<tt class="xref c c-macro docutils literal"><span class="pre">MPD_Rounded</span></tt>, <tt class="xref c c-macro docutils literal"><span class="pre">MPD_Subnormal</span></tt>, <tt class="xref c c-macro docutils literal"><span class="pre">MPD_Underflow</span></tt></p>
</div>
</div>
<div class="section" id="nan-handling">
<h2>NaN Handling</h2>
<p>These functions are convenience functions that take care of the elaborate
NaN handling rules. They are meant to be used at the beginning of composite
functions.</p>
<div class="section" id="check-nan">
<h3>check-nan</h3>
<span class="target" id="std:topic-mpd_qcheck_nan"></span><div class="highlight-c" id="std:topic-mpd_check_nan"><div class="highlight"><pre><span class="kt">int</span> <span class="nf">mpd_qcheck_nan</span><span class="p">(</span><span class="kt">mpd_t</span> <span class="o">*</span><span class="n">result</span><span class="p">,</span> <span class="k">const</span> <span class="kt">mpd_t</span> <span class="o">*</span><span class="n">a</span><span class="p">,</span> <span class="k">const</span> <span class="kt">mpd_context_t</span> <span class="o">*</span><span class="n">ctx</span><span class="p">,</span>
<span class="kt">uint32_t</span> <span class="o">*</span><span class="n">status</span><span class="p">);</span>
<span class="kt">int</span> <span class="nf">mpd_check_nan</span><span class="p">(</span><span class="kt">mpd_t</span> <span class="o">*</span><span class="n">result</span><span class="p">,</span> <span class="k">const</span> <span class="kt">mpd_t</span> <span class="o">*</span><span class="n">a</span><span class="p">,</span> <span class="kt">mpd_context_t</span> <span class="o">*</span><span class="n">ctx</span><span class="p">);</span>
</pre></div>
</div>
<p>If <em>a</em> is NaN or sNaN, set <em>result</em> to qNaN, copy any payload, apply <em>ctx</em>
to the payload and return 1. If <em>a</em> is sNaN, additionally set
<tt class="xref c c-macro docutils literal"><span class="pre">MPD_Invalid_operation</span></tt>.</p>
<p>Otherwise, <em>result</em> is undefined and the return value is 0.</p>
</div>
<div class="section" id="check-nans">
<h3>check-nans</h3>
<span class="target" id="std:topic-mpd_qcheck_nans"></span><div class="highlight-c" id="std:topic-mpd_check_nans"><div class="highlight"><pre><span class="kt">int</span> <span class="nf">mpd_qcheck_nans</span><span class="p">(</span><span class="kt">mpd_t</span> <span class="o">*</span><span class="n">result</span><span class="p">,</span> <span class="k">const</span> <span class="kt">mpd_t</span> <span class="o">*</span><span class="n">a</span><span class="p">,</span> <span class="k">const</span> <span class="kt">mpd_t</span> <span class="o">*</span><span class="n">b</span><span class="p">,</span>
<span class="k">const</span> <span class="kt">mpd_context_t</span> <span class="o">*</span><span class="n">ctx</span><span class="p">,</span> <span class="kt">uint32_t</span> <span class="o">*</span><span class="n">status</span><span class="p">);</span>
<span class="kt">int</span> <span class="nf">mpd_check_nans</span><span class="p">(</span><span class="kt">mpd_t</span> <span class="o">*</span><span class="n">result</span><span class="p">,</span> <span class="k">const</span> <span class="kt">mpd_t</span> <span class="o">*</span><span class="n">a</span><span class="p">,</span> <span class="k">const</span> <span class="kt">mpd_t</span> <span class="o">*</span><span class="n">b</span><span class="p">,</span>
<span class="kt">mpd_context_t</span> <span class="o">*</span><span class="n">ctx</span><span class="p">);</span>
</pre></div>
</div>
<p>If either operand is NaN or sNaN, apply the precedence rules, set <em>result</em>
to qNaN, copy any payload, apply <em>ctx</em> to the payload and return 1. If
one of the operands is sNaN, additionally set <tt class="xref c c-macro docutils literal"><span class="pre">MPD_Invalid_operation</span></tt>.</p>
<p>Otherwise, <em>result</em> is undefined and the return value is 0.</p>
</div>
</div>
<div class="section" id="shifting-and-rotating">
<h2>Shifting and Rotating</h2>
<span class="target" id="std:topic-mpd_qshift"></span><div class="section" id="shift">
<span id="std:topic-mpd_shift"></span><h3>shift</h3>
<div class="highlight-c"><div class="highlight"><pre><span class="kt">void</span> <span class="nf">mpd_qshift</span><span class="p">(</span><span class="kt">mpd_t</span> <span class="o">*</span><span class="n">result</span><span class="p">,</span> <span class="k">const</span> <span class="kt">mpd_t</span> <span class="o">*</span><span class="n">a</span><span class="p">,</span> <span class="k">const</span> <span class="kt">mpd_t</span> <span class="o">*</span><span class="n">b</span><span class="p">,</span>
<span class="k">const</span> <span class="kt">mpd_context_t</span> <span class="o">*</span><span class="n">ctx</span><span class="p">,</span> <span class="kt">uint32_t</span> <span class="o">*</span><span class="n">status</span><span class="p">);</span>
<span class="kt">void</span> <span class="nf">mpd_shift</span><span class="p">(</span><span class="kt">mpd_t</span> <span class="o">*</span><span class="n">result</span><span class="p">,</span> <span class="k">const</span> <span class="kt">mpd_t</span> <span class="o">*</span><span class="n">a</span><span class="p">,</span> <span class="k">const</span> <span class="kt">mpd_t</span> <span class="o">*</span><span class="n">b</span><span class="p">,</span>
<span class="kt">mpd_context_t</span> <span class="o">*</span><span class="n">ctx</span><span class="p">);</span>
</pre></div>
</div>
<p>Set <em>result</em> to <em>a</em> shifted by <em>b</em> places. <em>b</em> must be in the range
[<em>-prec</em>, <em>prec</em>]. A negative <em>b</em> indicates a right shift, a positive
<em>b</em> a left shift. Digits that do not fit are discarded.</p>
<span class="target" id="std:topic-mpd_qshiftn"></span></div>
<div class="section" id="shiftn">
<span id="std:topic-mpd_shiftn"></span><h3>shiftn</h3>
<div class="highlight-c"><div class="highlight"><pre><span class="kt">void</span> <span class="nf">mpd_qshiftn</span><span class="p">(</span><span class="kt">mpd_t</span> <span class="o">*</span><span class="n">result</span><span class="p">,</span> <span class="k">const</span> <span class="kt">mpd_t</span> <span class="o">*</span><span class="n">a</span><span class="p">,</span> <span class="kt">mpd_ssize_t</span> <span class="n">n</span><span class="p">,</span>
<span class="k">const</span> <span class="kt">mpd_context_t</span> <span class="o">*</span><span class="n">ctx</span><span class="p">,</span> <span class="kt">uint32_t</span> <span class="o">*</span><span class="n">status</span><span class="p">);</span>
<span class="kt">void</span> <span class="nf">mpd_shiftn</span><span class="p">(</span><span class="kt">mpd_t</span> <span class="o">*</span><span class="n">result</span><span class="p">,</span> <span class="k">const</span> <span class="kt">mpd_t</span> <span class="o">*</span><span class="n">a</span><span class="p">,</span> <span class="kt">mpd_ssize_t</span> <span class="n">n</span><span class="p">,</span>
<span class="kt">mpd_context_t</span> <span class="o">*</span><span class="n">ctx</span><span class="p">);</span>
</pre></div>
</div>
<p>Like <tt class="xref c c-func docutils literal"><span class="pre">mpd_qshift</span></tt>, only that the number of places is specified by a
C integer type rather than a decimal. This function is not part of the
specification.</p>
<span class="target" id="std:topic-mpd_qshiftl"></span></div>
<div class="section" id="shiftl">
<span id="std:topic-mpd_shiftl"></span><h3>shiftl</h3>
<div class="highlight-c"><div class="highlight"><pre><span class="kt">int</span> <span class="nf">mpd_qshiftl</span><span class="p">(</span><span class="kt">mpd_t</span> <span class="o">*</span><span class="n">result</span><span class="p">,</span> <span class="k">const</span> <span class="kt">mpd_t</span> <span class="o">*</span><span class="n">a</span><span class="p">,</span> <span class="kt">mpd_ssize_t</span> <span class="n">n</span><span class="p">,</span>
<span class="kt">uint32_t</span> <span class="o">*</span><span class="n">status</span><span class="p">);</span>
<span class="kt">void</span> <span class="nf">mpd_shiftl</span><span class="p">(</span><span class="kt">mpd_t</span> <span class="o">*</span><span class="n">result</span><span class="p">,</span> <span class="k">const</span> <span class="kt">mpd_t</span> <span class="o">*</span><span class="n">a</span><span class="p">,</span> <span class="kt">mpd_ssize_t</span> <span class="n">n</span><span class="p">,</span>
<span class="kt">mpd_context_t</span> <span class="o">*</span><span class="n">ctx</span><span class="p">);</span>
</pre></div>
</div>
<p>Set <em>result</em> to <em>a</em>, shifted by <em>n</em> places to the left. <em>a</em> must not be
a special number. Digits are never discarded, so the coefficient of
<em>result</em> might exceed <em>prec</em>. Return 1 on success. On failure, return 0
and add <tt class="xref c c-macro docutils literal"><span class="pre">MPD_Malloc_error</span></tt> to <em>status</em>.</p>
<p>This function is not part of the specification.</p>
<span class="target" id="std:topic-mpd_qshiftr"></span></div>
<div class="section" id="shiftr">
<span id="std:topic-mpd_shiftr"></span><h3>shiftr</h3>
<div class="highlight-c"><div class="highlight"><pre><span class="kt">mpd_uint_t</span> <span class="nf">mpd_qshiftr</span><span class="p">(</span><span class="kt">mpd_t</span> <span class="o">*</span><span class="n">result</span><span class="p">,</span> <span class="k">const</span> <span class="kt">mpd_t</span> <span class="o">*</span><span class="n">a</span><span class="p">,</span> <span class="kt">mpd_ssize_t</span> <span class="n">n</span><span class="p">,</span>
<span class="kt">uint32_t</span> <span class="o">*</span><span class="n">status</span><span class="p">);</span>
<span class="kt">mpd_uint_t</span> <span class="nf">mpd_shiftr</span><span class="p">(</span><span class="kt">mpd_t</span> <span class="o">*</span><span class="n">result</span><span class="p">,</span> <span class="k">const</span> <span class="kt">mpd_t</span> <span class="o">*</span><span class="n">a</span><span class="p">,</span> <span class="kt">mpd_ssize_t</span> <span class="n">n</span><span class="p">,</span>
<span class="kt">mpd_context_t</span> <span class="o">*</span><span class="n">ctx</span><span class="p">);</span>
</pre></div>
</div>
<p>Set <em>result</em> to <em>a</em>, shifted by <em>n</em> places to the right. <em>a</em> must not be
a special number. On success, return the digit relevant for rounding.
On failure, return <tt class="xref c c-macro docutils literal"><span class="pre">MPD_UINT_MAX</span></tt> and add <tt class="xref c c-macro docutils literal"><span class="pre">MPD_Malloc_error</span></tt>
to <em>status</em>.</p>
<p>This function is not part of the specification.</p>
</div>
<div class="section" id="shiftr-inplace">
<span id="std:topic-mpd_qshiftr_inplace"></span><h3>shiftr-inplace</h3>
<div class="highlight-c"><div class="highlight"><pre><span class="kt">mpd_uint_t</span> <span class="n">mpd_qshiftr_inplace</span><span class="p">(</span><span class="kt">mpd_t</span> <span class="o">*</span><span class="n">result</span><span class="p">,</span> <span class="kt">mpd_ssize_t</span> <span class="n">n</span><span class="p">)</span>
</pre></div>
</div>
<p>Like <tt class="xref c c-func docutils literal"><span class="pre">mpd_qshiftr</span></tt>, but shifts <em>result</em> in place. <em>result</em>
must not be a special number. This function cannot fail.</p>
</div>
<div class="section" id="rotate">
<h3>rotate</h3>
<span class="target" id="std:topic-mpd_qrotate"></span><div class="highlight-c" id="std:topic-mpd_rotate"><div class="highlight"><pre><span class="kt">void</span> <span class="nf">mpd_qrotate</span><span class="p">(</span><span class="kt">mpd_t</span> <span class="o">*</span><span class="n">result</span><span class="p">,</span> <span class="k">const</span> <span class="kt">mpd_t</span> <span class="o">*</span><span class="n">a</span><span class="p">,</span> <span class="k">const</span> <span class="kt">mpd_t</span> <span class="o">*</span><span class="n">b</span><span class="p">,</span>
<span class="k">const</span> <span class="kt">mpd_context_t</span> <span class="o">*</span><span class="n">ctx</span><span class="p">,</span> <span class="kt">uint32_t</span> <span class="o">*</span><span class="n">status</span><span class="p">);</span>
<span class="kt">void</span> <span class="nf">mpd_rotate</span><span class="p">(</span><span class="kt">mpd_t</span> <span class="o">*</span><span class="n">result</span><span class="p">,</span> <span class="k">const</span> <span class="kt">mpd_t</span> <span class="o">*</span><span class="n">a</span><span class="p">,</span> <span class="k">const</span> <span class="kt">mpd_t</span> <span class="o">*</span><span class="n">b</span><span class="p">,</span>
<span class="kt">mpd_context_t</span> <span class="o">*</span><span class="n">ctx</span><span class="p">);</span>
</pre></div>
</div>
<p>Set <em>result</em> to <em>a</em> rotated by <em>b</em> places. <em>b</em> must be in the range [<em>-prec</em>, <em>prec</em>].
A negative <em>b</em> indicates a right rotation, a positive <em>b</em> a left rotation.</p>
</div>
</div>
<div class="section" id="logical-operations">
<h2>Logical Operations</h2>
<p>Logical operands are finite numbers with a sign of 0, an exponent of 0 and
a coefficient consisting only of ones and zeros.</p>
<span class="target" id="std:topic-mpd_qand"></span><div class="section" id="and">
<span id="std:topic-mpd_and"></span><h3>and</h3>
<div class="highlight-c"><div class="highlight"><pre><span class="kt">void</span> <span class="nf">mpd_qand</span><span class="p">(</span><span class="kt">mpd_t</span> <span class="o">*</span><span class="n">result</span><span class="p">,</span> <span class="k">const</span> <span class="kt">mpd_t</span> <span class="o">*</span><span class="n">a</span><span class="p">,</span> <span class="k">const</span> <span class="kt">mpd_t</span> <span class="o">*</span><span class="n">b</span><span class="p">,</span>
<span class="k">const</span> <span class="kt">mpd_context_t</span> <span class="o">*</span><span class="n">ctx</span><span class="p">,</span> <span class="kt">uint32_t</span> <span class="o">*</span><span class="n">status</span><span class="p">);</span>
<span class="kt">void</span> <span class="nf">mpd_and</span><span class="p">(</span><span class="kt">mpd_t</span> <span class="o">*</span><span class="n">result</span><span class="p">,</span> <span class="k">const</span> <span class="kt">mpd_t</span> <span class="o">*</span><span class="n">a</span><span class="p">,</span> <span class="k">const</span> <span class="kt">mpd_t</span> <span class="o">*</span><span class="n">b</span><span class="p">,</span>
<span class="kt">mpd_context_t</span> <span class="o">*</span><span class="n">ctx</span><span class="p">);</span>
</pre></div>
</div>
<p>Set <em>result</em> to the digit-wise <em>logical and</em> of <em>a</em> and <em>b</em>.</p>
<span class="target" id="std:topic-mpd_qor"></span></div>
<div class="section" id="or">
<span id="std:topic-mpd_or"></span><h3>or</h3>
<div class="highlight-c"><div class="highlight"><pre><span class="kt">void</span> <span class="nf">mpd_qor</span><span class="p">(</span><span class="kt">mpd_t</span> <span class="o">*</span><span class="n">result</span><span class="p">,</span> <span class="k">const</span> <span class="kt">mpd_t</span> <span class="o">*</span><span class="n">a</span><span class="p">,</span> <span class="k">const</span> <span class="kt">mpd_t</span> <span class="o">*</span><span class="n">b</span><span class="p">,</span>
<span class="k">const</span> <span class="kt">mpd_context_t</span> <span class="o">*</span><span class="n">ctx</span><span class="p">,</span> <span class="kt">uint32_t</span> <span class="o">*</span><span class="n">status</span><span class="p">);</span>
<span class="kt">void</span> <span class="nf">mpd_or</span><span class="p">(</span><span class="kt">mpd_t</span> <span class="o">*</span><span class="n">result</span><span class="p">,</span> <span class="k">const</span> <span class="kt">mpd_t</span> <span class="o">*</span><span class="n">a</span><span class="p">,</span> <span class="k">const</span> <span class="kt">mpd_t</span> <span class="o">*</span><span class="n">b</span><span class="p">,</span>
<span class="kt">mpd_context_t</span> <span class="o">*</span><span class="n">ctx</span><span class="p">);</span>
</pre></div>
</div>
<p>Set <em>result</em> to the digit-wise <em>logical or</em> of <em>a</em> and <em>b</em>.</p>
<span class="target" id="std:topic-mpd_qxor"></span></div>
<div class="section" id="xor">
<span id="std:topic-mpd_xor"></span><h3>xor</h3>
<div class="highlight-c"><div class="highlight"><pre><span class="kt">void</span> <span class="nf">mpd_qxor</span><span class="p">(</span><span class="kt">mpd_t</span> <span class="o">*</span><span class="n">result</span><span class="p">,</span> <span class="k">const</span> <span class="kt">mpd_t</span> <span class="o">*</span><span class="n">a</span><span class="p">,</span> <span class="k">const</span> <span class="kt">mpd_t</span> <span class="o">*</span><span class="n">b</span><span class="p">,</span>
<span class="k">const</span> <span class="kt">mpd_context_t</span> <span class="o">*</span><span class="n">ctx</span><span class="p">,</span> <span class="kt">uint32_t</span> <span class="o">*</span><span class="n">status</span><span class="p">);</span>
<span class="kt">void</span> <span class="nf">mpd_xor</span><span class="p">(</span><span class="kt">mpd_t</span> <span class="o">*</span><span class="n">result</span><span class="p">,</span> <span class="k">const</span> <span class="kt">mpd_t</span> <span class="o">*</span><span class="n">a</span><span class="p">,</span> <span class="k">const</span> <span class="kt">mpd_t</span> <span class="o">*</span><span class="n">b</span><span class="p">,</span>
<span class="kt">mpd_context_t</span> <span class="o">*</span><span class="n">ctx</span><span class="p">);</span>
</pre></div>
</div>
<p>Set <em>result</em> to the digit-wise <em>logical xor</em> of <em>a</em> and <em>b</em>.</p>
<span class="target" id="std:topic-mpd_qinvert"></span></div>
<div class="section" id="invert">
<span id="std:topic-mpd_invert"></span><h3>invert</h3>
<div class="highlight-c"><div class="highlight"><pre><span class="kt">void</span> <span class="nf">mpd_qinvert</span><span class="p">(</span><span class="kt">mpd_t</span> <span class="o">*</span><span class="n">result</span><span class="p">,</span> <span class="k">const</span> <span class="kt">mpd_t</span> <span class="o">*</span><span class="n">a</span><span class="p">,</span> <span class="k">const</span> <span class="kt">mpd_context_t</span> <span class="o">*</span><span class="n">ctx</span><span class="p">,</span>
<span class="kt">uint32_t</span> <span class="o">*</span><span class="n">status</span><span class="p">);</span>
<span class="kt">void</span> <span class="nf">mpd_invert</span><span class="p">(</span><span class="kt">mpd_t</span> <span class="o">*</span><span class="n">result</span><span class="p">,</span> <span class="k">const</span> <span class="kt">mpd_t</span> <span class="o">*</span><span class="n">a</span><span class="p">,</span> <span class="kt">mpd_context_t</span> <span class="o">*</span><span class="n">ctx</span><span class="p">);</span>
</pre></div>
</div>
<p>Set <em>result</em> to the digit-wise <em>logical inversion</em> of <em>a</em>.</p>
</div>
</div>
<div class="section" id="base-conversions">
<h2>Base Conversions</h2>
<p>Functions for converting decimals to multi-precision integers and vice
versa. Decimals that are exported must be integers.</p>
<div class="section" id="importing">
<h3>Importing</h3>
<span class="target" id="std:topic-mpd_qimport_u16"></span><div class="highlight-c" id="std:topic-mpd_import_u16"><div class="highlight"><pre><span class="kt">void</span> <span class="nf">mpd_qimport_u16</span><span class="p">(</span><span class="kt">mpd_t</span> <span class="o">*</span><span class="n">result</span><span class="p">,</span> <span class="k">const</span> <span class="kt">uint16_t</span> <span class="o">*</span><span class="n">srcdata</span><span class="p">,</span>
<span class="kt">size_t</span> <span class="n">srclen</span><span class="p">,</span> <span class="kt">uint8_t</span> <span class="n">srcsign</span><span class="p">,</span> <span class="kt">uint32_t</span> <span class="n">srcbase</span><span class="p">,</span>
<span class="k">const</span> <span class="kt">mpd_context_t</span> <span class="o">*</span><span class="n">ctx</span><span class="p">,</span> <span class="kt">uint32_t</span> <span class="o">*</span><span class="n">status</span><span class="p">);</span>
<span class="kt">void</span> <span class="nf">mpd_import_u16</span><span class="p">(</span><span class="kt">mpd_t</span> <span class="o">*</span><span class="n">result</span><span class="p">,</span> <span class="k">const</span> <span class="kt">uint16_t</span> <span class="o">*</span><span class="n">srcdata</span><span class="p">,</span>
<span class="kt">size_t</span> <span class="n">srclen</span><span class="p">,</span> <span class="kt">uint8_t</span> <span class="n">srcsign</span><span class="p">,</span> <span class="kt">uint32_t</span> <span class="n">srcbase</span><span class="p">,</span>
<span class="kt">mpd_context_t</span> <span class="o">*</span><span class="n">ctx</span><span class="p">);</span>
</pre></div>
</div>
<p>Convert a multi-precision integer at <em>srcdata</em> with base <em>srcbase</em> to a
decimal. The least significant word is <em>srcdata</em>[0].</p>
<p><em>srcsign</em> is <tt class="xref c c-macro docutils literal"><span class="pre">MPD_POS</span></tt> for positive and <tt class="xref c c-macro docutils literal"><span class="pre">MPD_NEG</span></tt> for
negative, <em>srclen</em> the length of <em>srcdata</em>.</p>
<p>Valid bases are in the range 2 <= <em>srcbase</em> <= <tt class="xref c c-macro docutils literal"><span class="pre">UINT16_MAX</span></tt> + 1.</p>
<span class="target" id="std:topic-mpd_qimport_u32"></span><div class="highlight-c" id="std:topic-mpd_import_u32"><div class="highlight"><pre><span class="kt">void</span> <span class="nf">mpd_qimport_u32</span><span class="p">(</span><span class="kt">mpd_t</span> <span class="o">*</span><span class="n">result</span><span class="p">,</span> <span class="k">const</span> <span class="kt">uint32_t</span> <span class="o">*</span><span class="n">srcdata</span><span class="p">,</span>
<span class="kt">size_t</span> <span class="n">srclen</span><span class="p">,</span> <span class="kt">uint8_t</span> <span class="n">srcsign</span><span class="p">,</span> <span class="kt">uint32_t</span> <span class="n">srcbase</span><span class="p">,</span>
<span class="k">const</span> <span class="kt">mpd_context_t</span> <span class="o">*</span><span class="n">ctx</span><span class="p">,</span> <span class="kt">uint32_t</span> <span class="o">*</span><span class="n">status</span><span class="p">);</span>
<span class="kt">void</span> <span class="nf">mpd_import_u32</span><span class="p">(</span><span class="kt">mpd_t</span> <span class="o">*</span><span class="n">result</span><span class="p">,</span> <span class="k">const</span> <span class="kt">uint32_t</span> <span class="o">*</span><span class="n">srcdata</span><span class="p">,</span>
<span class="kt">size_t</span> <span class="n">srclen</span><span class="p">,</span> <span class="kt">uint8_t</span> <span class="n">srcsign</span><span class="p">,</span> <span class="kt">uint32_t</span> <span class="n">base</span><span class="p">,</span>
<span class="kt">mpd_context_t</span> <span class="o">*</span><span class="n">ctx</span><span class="p">);</span>
</pre></div>
</div>
<p>Convert a multi-precision integer at <em>srcdata</em> with base <em>srcbase</em> to a
decimal. The least significant word is <em>srcdata</em>[0].</p>
<p><em>srcsign</em> is <tt class="xref c c-macro docutils literal"><span class="pre">MPD_POS</span></tt> for positive and <tt class="xref c c-macro docutils literal"><span class="pre">MPD_NEG</span></tt> for
negative, <em>srclen</em> the length of <em>srcdata</em>.</p>
<p>Valid bases are in the range 2 <= <em>srcbase</em> <= <tt class="xref c c-macro docutils literal"><span class="pre">UINT32_MAX</span></tt>.</p>
</div>
<div class="section" id="exporting">
<h3>Exporting</h3>
<div class="highlight-c" id="std:topic-mpd_sizeinbase"><div class="highlight"><pre><span class="n">mpd_sizeinbase</span><span class="p">(</span><span class="k">const</span> <span class="kt">mpd_t</span> <span class="o">*</span><span class="n">a</span><span class="p">,</span> <span class="kt">uint32_t</span> <span class="n">base</span><span class="p">);</span>
</pre></div>
</div>
<p>Return the number of words needed to represent a decimal when converted
to <em>base</em>. The decimal <em>must be an integer</em>, results are undefined for
non-integers.</p>
<span class="target" id="std:topic-mpd_qexport_u16"></span><div class="highlight-c" id="std:topic-mpd_export_u16"><div class="highlight"><pre><span class="kt">size_t</span> <span class="nf">mpd_qexport_u16</span><span class="p">(</span><span class="kt">uint16_t</span> <span class="o">**</span><span class="n">rdata</span><span class="p">,</span> <span class="kt">size_t</span> <span class="n">rlen</span><span class="p">,</span> <span class="kt">uint32_t</span> <span class="n">rbase</span><span class="p">,</span>
<span class="k">const</span> <span class="kt">mpd_t</span> <span class="o">*</span><span class="n">src</span><span class="p">,</span> <span class="kt">uint32_t</span> <span class="o">*</span><span class="n">status</span><span class="p">);</span>
<span class="kt">size_t</span> <span class="nf">mpd_export_u16</span><span class="p">(</span><span class="kt">uint16_t</span> <span class="o">**</span><span class="n">rdata</span><span class="p">,</span> <span class="kt">size_t</span> <span class="n">rlen</span><span class="p">,</span> <span class="kt">uint32_t</span> <span class="n">rbase</span><span class="p">,</span>
<span class="k">const</span> <span class="kt">mpd_t</span> <span class="o">*</span><span class="n">src</span><span class="p">,</span> <span class="kt">mpd_context_t</span> <span class="o">*</span><span class="n">ctx</span><span class="p">);</span>
</pre></div>
</div>
<p>Set <em>*rdata</em> to <em>src</em>, converted to a representation in base <em>rbase</em>.
The least significant word of the result is <em>rdata</em>[0]. <em>src</em> must be
an integer.</p>
<p>If <em>rdata</em> is NULL, space is allocated by the function and <em>rlen</em> is
irrelevant. In case of an error the allocated storage is freed and
rdata is set back to NULL.</p>
<p>If <em>rdata</em> is non-NULL, it <em>MUST</em> be allocated by one of libmpdec’s
allocation functions and <em>rlen</em> <em>MUST</em> be correct. If necessary, the
function will resize <em>rdata</em>. Resizing is slow and should not occur
if <em>rlen</em> has been obtained by a call to <tt class="xref c c-func docutils literal"><span class="pre">mpd_sizeinbase</span></tt>.
In case of an error the caller must free <em>rdata</em>.</p>
<p>Return value: In case of success, the length of the multi-precision integer
in the new base, <tt class="xref c c-macro docutils literal"><span class="pre">SIZE_MAX</span></tt> otherwise.</p>
<p>Valid bases are in the range 2 <= <em>rbase</em> <= <tt class="xref c c-macro docutils literal"><span class="pre">UINT16_MAX</span></tt> + 1.</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 2.4: </span><em>rdata</em> is now resized if necessary.</p>
</div>
<span class="target" id="std:topic-mpd_qexport_u32"></span><div class="highlight-c" id="std:topic-mpd_export_u32"><div class="highlight"><pre><span class="kt">size_t</span> <span class="nf">mpd_qexport_u32</span><span class="p">(</span><span class="kt">uint32_t</span> <span class="o">*</span><span class="n">rdata</span><span class="p">,</span> <span class="kt">size_t</span> <span class="n">rlen</span><span class="p">,</span> <span class="kt">uint32_t</span> <span class="n">rbase</span><span class="p">,</span>
<span class="k">const</span> <span class="kt">mpd_t</span> <span class="o">*</span><span class="n">src</span><span class="p">,</span> <span class="kt">uint32_t</span> <span class="o">*</span><span class="n">status</span><span class="p">);</span>
<span class="kt">size_t</span> <span class="nf">mpd_export_u32</span><span class="p">(</span><span class="kt">uint32_t</span> <span class="o">*</span><span class="n">rdata</span><span class="p">,</span> <span class="kt">size_t</span> <span class="n">rlen</span><span class="p">,</span> <span class="kt">uint32_t</span> <span class="n">rbase</span><span class="p">,</span>
<span class="k">const</span> <span class="kt">mpd_t</span> <span class="o">*</span><span class="n">src</span><span class="p">,</span> <span class="kt">mpd_context_t</span> <span class="o">*</span><span class="n">ctx</span><span class="p">);</span>
</pre></div>
</div>
<p>Set <em>*rdata</em> to <em>src</em>, converted to a representation in base <em>rbase</em>.
The least significant word of the result is <em>rdata</em>[0]. <em>src</em> must be
an integer.</p>
<p>If <em>rdata</em> is NULL, space is allocated by the function and <em>rlen</em> is
irrelevant. In case of an error the allocated storage is freed and
rdata is set back to NULL.</p>
<p>If <em>rdata</em> is non-NULL, it <em>MUST</em> be allocated by one of libmpdec’s
allocation functions and <em>rlen</em> <em>MUST</em> be correct. If necessary, the
function will resize <em>rdata</em>. Resizing is slow and should not occur if
<em>rlen</em> has been obtained by a call to <tt class="xref c c-func docutils literal"><span class="pre">mpd_sizeinbase</span></tt>. In case
of an error the caller must free <em>rdata</em>.</p>
<p>Return value: In case of success, the length of the multi-precision integer
in the new base, <tt class="xref c c-macro docutils literal"><span class="pre">SIZE_MAX</span></tt> otherwise.</p>
<p>Valid bases are in the range 2 <= <em>rbase</em> <= <tt class="xref c c-macro docutils literal"><span class="pre">UINT32_MAX</span></tt>.</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 2.4: </span><em>rdata</em> is now resized if necessary.</p>
</div>
</div>
</div>
<div class="section" id="required-functions">
<h2>Required Functions</h2>
<p>The functions in this section are not needed for this implementation.
They are provided for full compliance with the specification.</p>
<div class="highlight-c" id="std:topic-mpd_canonical"><div class="highlight"><pre><span class="kt">void</span> <span class="nf">mpd_canonical</span><span class="p">(</span><span class="kt">mpd_t</span> <span class="o">*</span><span class="n">result</span><span class="p">,</span> <span class="k">const</span> <span class="kt">mpd_t</span> <span class="o">*</span><span class="n">a</span><span class="p">,</span> <span class="kt">mpd_context_t</span> <span class="o">*</span><span class="n">ctx</span><span class="p">);</span>
</pre></div>
</div>
<p>Same as <tt class="xref c c-func docutils literal"><span class="pre">mpd_copy</span></tt>.</p>
<div class="highlight-c" id="std:topic-mpd_iscanonical"><div class="highlight"><pre><span class="kt">int</span> <span class="nf">mpd_iscanonical</span><span class="p">(</span><span class="k">const</span> <span class="kt">mpd_t</span> <span class="o">*</span><span class="n">dec</span><span class="p">);</span>
</pre></div>
</div>
<p>Return 1, for compatibility with the standard.</p>
<div class="highlight-c" id="std:topic-mpd_radix"><div class="highlight"><pre><span class="kt">long</span> <span class="nf">mpd_radix</span><span class="p">(</span><span class="kt">void</span><span class="p">);</span>
</pre></div>
</div>
<p>Return 10.</p>
</div>
<div class="section" id="library-version">
<h2>Library version</h2>
<div class="highlight-c" id="std:topic-mpd_version"><div class="highlight"><pre><span class="cm">/* Macros defining the components of the version as integers. */</span>
<span class="n">MPD_MAJOR_VERSION</span>
<span class="n">MPD_MINOR_VERSION</span>
<span class="n">MPD_MICRO_VERSION</span>
<span class="cm">/* Macro defining the complete version as a string. */</span>
<span class="n">MPD_VERSION</span>
<span class="k">const</span> <span class="kt">char</span> <span class="o">*</span><span class="n">mpd_version</span><span class="p">(</span><span class="kt">void</span><span class="p">);</span>
</pre></div>
</div>
<p>Library version information. <tt class="xref c c-func docutils literal"><span class="pre">mpd_version</span></tt> returns the MPD_VERSION macro
from the header that the library was compiled with.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 2.4.</span></p>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="memory.html" title="Advanced Memory Handling"
>next</a></li>
<li class="right" >
<a href="arithmetic.html" title="Arithmetic Functions"
>previous</a> |</li>
<li><a href="http://www.bytereef.org/mpdecimal/index.html">project home</a></li>
</ul>
</div>
<div class="footer">
© Copyright 2010-2016, Stefan Krah.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
</div>
</body>
</html>
|