You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
140 lines
7.1 KiB
HTML
140 lines
7.1 KiB
HTML
4 years ago
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||
|
<html>
|
||
|
<!-- This manual documents how to install and use the Multiple Precision
|
||
|
Floating-Point Reliable Library, version 3.1.4.
|
||
|
|
||
|
Copyright 1991, 1993-2016 Free Software Foundation, Inc.
|
||
|
|
||
|
Permission is granted to copy, distribute and/or modify this document under
|
||
|
the terms of the GNU Free Documentation License, Version 1.2 or any later
|
||
|
version published by the Free Software Foundation; with no Invariant Sections,
|
||
|
with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the
|
||
|
license is included in GNU Free Documentation License. -->
|
||
|
<!-- Created by GNU Texinfo 6.4, http://www.gnu.org/software/texinfo/ -->
|
||
|
<head>
|
||
|
<title>Compatibility with MPF (GNU MPFR 3.1.4)</title>
|
||
|
|
||
|
<meta name="description" content="How to install and use GNU MPFR, a library for reliable multiple precision
|
||
|
floating-point arithmetic, version 3.1.4.">
|
||
|
<meta name="keywords" content="Compatibility with MPF (GNU MPFR 3.1.4)">
|
||
|
<meta name="resource-type" content="document">
|
||
|
<meta name="distribution" content="global">
|
||
|
<meta name="Generator" content="makeinfo">
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||
|
<link href="index.html#Top" rel="start" title="Top">
|
||
|
<link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
|
||
|
<link href="MPFR-Interface.html#MPFR-Interface" rel="up" title="MPFR Interface">
|
||
|
<link href="Custom-Interface.html#Custom-Interface" rel="next" title="Custom Interface">
|
||
|
<link href="Exception-Related-Functions.html#Exception-Related-Functions" rel="prev" title="Exception Related Functions">
|
||
|
<style type="text/css">
|
||
|
<!--
|
||
|
a.summary-letter {text-decoration: none}
|
||
|
blockquote.indentedblock {margin-right: 0em}
|
||
|
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
|
||
|
blockquote.smallquotation {font-size: smaller}
|
||
|
div.display {margin-left: 3.2em}
|
||
|
div.example {margin-left: 3.2em}
|
||
|
div.lisp {margin-left: 3.2em}
|
||
|
div.smalldisplay {margin-left: 3.2em}
|
||
|
div.smallexample {margin-left: 3.2em}
|
||
|
div.smalllisp {margin-left: 3.2em}
|
||
|
kbd {font-style: oblique}
|
||
|
pre.display {font-family: inherit}
|
||
|
pre.format {font-family: inherit}
|
||
|
pre.menu-comment {font-family: serif}
|
||
|
pre.menu-preformatted {font-family: serif}
|
||
|
pre.smalldisplay {font-family: inherit; font-size: smaller}
|
||
|
pre.smallexample {font-size: smaller}
|
||
|
pre.smallformat {font-family: inherit; font-size: smaller}
|
||
|
pre.smalllisp {font-size: smaller}
|
||
|
span.nolinebreak {white-space: nowrap}
|
||
|
span.roman {font-family: initial; font-weight: normal}
|
||
|
span.sansserif {font-family: sans-serif; font-weight: normal}
|
||
|
ul.no-bullet {list-style: none}
|
||
|
-->
|
||
|
</style>
|
||
|
|
||
|
|
||
|
</head>
|
||
|
|
||
|
<body lang="en">
|
||
|
<a name="Compatibility-with-MPF"></a>
|
||
|
<div class="header">
|
||
|
<p>
|
||
|
Next: <a href="Custom-Interface.html#Custom-Interface" accesskey="n" rel="next">Custom Interface</a>, Previous: <a href="Exception-Related-Functions.html#Exception-Related-Functions" accesskey="p" rel="prev">Exception Related Functions</a>, Up: <a href="MPFR-Interface.html#MPFR-Interface" accesskey="u" rel="up">MPFR Interface</a> [<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
||
|
</div>
|
||
|
<hr>
|
||
|
<a name="index-Compatibility-with-MPF"></a>
|
||
|
<a name="Compatibility-With-MPF"></a>
|
||
|
<h3 class="section">5.14 Compatibility With MPF</h3>
|
||
|
|
||
|
<p>A header file <samp>mpf2mpfr.h</samp> is included in the distribution of MPFR for
|
||
|
compatibility with the GNU MP class MPF.
|
||
|
By inserting the following two lines after the <code>#include <gmp.h></code> line,
|
||
|
</p><div class="example">
|
||
|
<pre class="example">#include <mpfr.h>
|
||
|
#include <mpf2mpfr.h>
|
||
|
</pre></div>
|
||
|
<p>any program written for
|
||
|
MPF can be compiled directly with MPFR without any changes
|
||
|
(except the <code>gmp_printf</code> functions will not work for arguments of type
|
||
|
<code>mpfr_t</code>).
|
||
|
All operations are then performed with the default MPFR rounding mode,
|
||
|
which can be reset with <code>mpfr_set_default_rounding_mode</code>.
|
||
|
</p>
|
||
|
<p>Warning: the <code>mpf_init</code> and <code>mpf_init2</code> functions initialize
|
||
|
to zero, whereas the corresponding MPFR functions initialize to NaN:
|
||
|
this is useful to detect uninitialized values, but is slightly incompatible
|
||
|
with MPF.
|
||
|
</p>
|
||
|
<dl>
|
||
|
<dt><a name="index-mpfr_005fset_005fprec_005fraw"></a>Function: <em>void</em> <strong>mpfr_set_prec_raw</strong> <em>(mpfr_t <var>x</var>, mpfr_prec_t <var>prec</var>)</em></dt>
|
||
|
<dd><p>Reset the precision of <var>x</var> to be <strong>exactly</strong> <var>prec</var> bits.
|
||
|
The only difference with <code>mpfr_set_prec</code> is that <var>prec</var> is assumed to
|
||
|
be small enough so that the significand fits into the current allocated memory
|
||
|
space for <var>x</var>. Otherwise the behavior is undefined.
|
||
|
</p></dd></dl>
|
||
|
|
||
|
<dl>
|
||
|
<dt><a name="index-mpfr_005feq"></a>Function: <em>int</em> <strong>mpfr_eq</strong> <em>(mpfr_t <var>op1</var>, mpfr_t <var>op2</var>, unsigned long int <var>op3</var>)</em></dt>
|
||
|
<dd><p>Return non-zero if <var>op1</var> and <var>op2</var> are both non-zero ordinary
|
||
|
numbers with the same exponent and the same first <var>op3</var> bits, both
|
||
|
zero, or both infinities of the same sign. Return zero otherwise.
|
||
|
This function is defined for compatibility with MPF, we do not recommend
|
||
|
to use it otherwise.
|
||
|
Do not use it either if
|
||
|
you want to know whether two numbers are close to each other; for instance,
|
||
|
1.011111 and 1.100000 are regarded as different for any value of
|
||
|
<var>op3</var> larger than 1.
|
||
|
</p></dd></dl>
|
||
|
|
||
|
<dl>
|
||
|
<dt><a name="index-mpfr_005freldiff"></a>Function: <em>void</em> <strong>mpfr_reldiff</strong> <em>(mpfr_t <var>rop</var>, mpfr_t <var>op1</var>, mpfr_t <var>op2</var>, mpfr_rnd_t <var>rnd</var>)</em></dt>
|
||
|
<dd><p>Compute the relative difference between <var>op1</var> and <var>op2</var>
|
||
|
and store the result in <var>rop</var>.
|
||
|
This function does not guarantee the correct rounding on the relative
|
||
|
difference; it just computes <em>|<var>op1</var>-<var>op2</var>|/<var>op1</var></em>, using the
|
||
|
precision of <var>rop</var> and the rounding mode <var>rnd</var> for all operations.
|
||
|
</p></dd></dl>
|
||
|
|
||
|
<dl>
|
||
|
<dt><a name="index-mpfr_005fmul_005f2exp"></a>Function: <em>int</em> <strong>mpfr_mul_2exp</strong> <em>(mpfr_t <var>rop</var>, mpfr_t <var>op1</var>, unsigned long int <var>op2</var>, mpfr_rnd_t <var>rnd</var>)</em></dt>
|
||
|
<dt><a name="index-mpfr_005fdiv_005f2exp"></a>Function: <em>int</em> <strong>mpfr_div_2exp</strong> <em>(mpfr_t <var>rop</var>, mpfr_t <var>op1</var>, unsigned long int <var>op2</var>, mpfr_rnd_t <var>rnd</var>)</em></dt>
|
||
|
<dd><p>These functions are identical to <code>mpfr_mul_2ui</code> and <code>mpfr_div_2ui</code>
|
||
|
respectively.
|
||
|
These functions are only kept for compatibility with MPF, one should
|
||
|
prefer <code>mpfr_mul_2ui</code> and <code>mpfr_div_2ui</code> otherwise.
|
||
|
</p></dd></dl>
|
||
|
|
||
|
|
||
|
<hr>
|
||
|
<div class="header">
|
||
|
<p>
|
||
|
Next: <a href="Custom-Interface.html#Custom-Interface" accesskey="n" rel="next">Custom Interface</a>, Previous: <a href="Exception-Related-Functions.html#Exception-Related-Functions" accesskey="p" rel="prev">Exception Related Functions</a>, Up: <a href="MPFR-Interface.html#MPFR-Interface" accesskey="u" rel="up">MPFR Interface</a> [<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
||
|
</div>
|
||
|
|
||
|
|
||
|
|
||
|
</body>
|
||
|
</html>
|