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.

100 lines
4.5 KiB
HTML

<!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>MPFR Variable Conventions (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="MPFR Variable Conventions (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-Basics.html#MPFR-Basics" rel="up" title="MPFR Basics">
<link href="Rounding-Modes.html#Rounding-Modes" rel="next" title="Rounding Modes">
<link href="Nomenclature-and-Types.html#Nomenclature-and-Types" rel="prev" title="Nomenclature and Types">
<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="MPFR-Variable-Conventions"></a>
<div class="header">
<p>
Next: <a href="Rounding-Modes.html#Rounding-Modes" accesskey="n" rel="next">Rounding Modes</a>, Previous: <a href="Nomenclature-and-Types.html#Nomenclature-and-Types" accesskey="p" rel="prev">Nomenclature and Types</a>, Up: <a href="MPFR-Basics.html#MPFR-Basics" accesskey="u" rel="up">MPFR Basics</a> &nbsp; [<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="MPFR-Variable-Conventions-1"></a>
<h3 class="section">4.3 MPFR Variable Conventions</h3>
<p>Before you can assign to an MPFR variable, you need to initialize it by calling
one of the special initialization functions. When you&rsquo;re done with a
variable, you need to clear it out, using one of the functions for that
purpose.
A variable should only be initialized once, or at least cleared out between
each initialization. After a variable has been initialized, it may be
assigned to any number of times.
For efficiency reasons, avoid to initialize and clear out a variable in loops.
Instead, initialize it before entering the loop, and clear it out after the
loop has exited.
You do not need to be concerned about allocating additional space for MPFR
variables, since any variable has a significand of fixed size.
Hence unless you change its precision, or clear and reinitialize it,
a floating-point variable will have the same allocated space during all its
life.
</p>
<p>As a general rule, all MPFR functions expect output arguments before input
arguments. This notation is based on an analogy with the assignment operator.
MPFR allows you to use the same variable for both input and output in the same
expression. For example, the main function for floating-point multiplication,
<code>mpfr_mul</code>, can be used like this: <code>mpfr_mul (x, x, x, rnd)</code>.
This
computes the square of <var>x</var> with rounding mode <code>rnd</code>
and puts the result back in <var>x</var>.
</p>
</body>
</html>