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.

125 lines
6.1 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>Input and Output Functions (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="Input and Output Functions (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="Formatted-Output-Functions.html#Formatted-Output-Functions" rel="next" title="Formatted Output Functions">
<link href="Special-Functions.html#Special-Functions" rel="prev" title="Special 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="Input-and-Output-Functions"></a>
<div class="header">
<p>
Next: <a href="Formatted-Output-Functions.html#Formatted-Output-Functions" accesskey="n" rel="next">Formatted Output Functions</a>, Previous: <a href="Special-Functions.html#Special-Functions" accesskey="p" rel="prev">Special Functions</a>, Up: <a href="MPFR-Interface.html#MPFR-Interface" accesskey="u" rel="up">MPFR Interface</a> &nbsp; [<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="index-Float-input-and-output-functions"></a>
<a name="index-Input-functions"></a>
<a name="index-Output-functions"></a>
<a name="index-I_002fO-functions"></a>
<a name="Input-and-Output-Functions-1"></a>
<h3 class="section">5.8 Input and Output Functions</h3>
<p>This section describes functions that perform input from an input/output
stream, and functions that output to an input/output stream.
Passing a null pointer for a <code>stream</code> to any of these functions will make
them read from <code>stdin</code> and write to <code>stdout</code>, respectively.
</p>
<p>When using any of these functions, you must include the <code>&lt;stdio.h&gt;</code>
standard header before <samp>mpfr.h</samp>, to allow <samp>mpfr.h</samp> to define
prototypes for these functions.
</p>
<dl>
<dt><a name="index-mpfr_005fout_005fstr"></a>Function: <em>size_t</em> <strong>mpfr_out_str</strong> <em>(FILE *<var>stream</var>, int <var>base</var>, size_t <var>n</var>, mpfr_t <var>op</var>, mpfr_rnd_t <var>rnd</var>)</em></dt>
<dd><p>Output <var>op</var> on stream <var>stream</var>, as a string of digits in
base <var>base</var>, rounded in the direction <var>rnd</var>.
The base may vary from 2 to 62. Print <var>n</var> significant digits exactly,
or if <var>n</var> is 0, enough digits so that <var>op</var> can be read back
exactly (see <code>mpfr_get_str</code>).
</p>
<p>In addition to the significant digits, a decimal point (defined by the
current locale) at the right of the
first digit and a trailing exponent in base 10, in the form &lsquo;<samp>eNNN</samp>&rsquo;,
are printed. If <var>base</var> is greater than 10, &lsquo;<samp>@</samp>&rsquo; will be used
instead of &lsquo;<samp>e</samp>&rsquo; as exponent delimiter.
</p>
<p>Return the number of characters written, or if an error occurred, return 0.
</p></dd></dl>
<dl>
<dt><a name="index-mpfr_005finp_005fstr"></a>Function: <em>size_t</em> <strong>mpfr_inp_str</strong> <em>(mpfr_t <var>rop</var>, FILE *<var>stream</var>, int <var>base</var>, mpfr_rnd_t <var>rnd</var>)</em></dt>
<dd><p>Input a string in base <var>base</var> from stream <var>stream</var>,
rounded in the direction <var>rnd</var>, and put the
read float in <var>rop</var>.
</p>
<p>This function reads a word (defined as a sequence of characters between
whitespace) and parses it using <code>mpfr_set_str</code>.
See the documentation of <code>mpfr_strtofr</code> for a detailed description
of the valid string formats.
</p>
<p>Return the number of bytes read, or if an error occurred, return 0.
</p></dd></dl>
<hr>
<div class="header">
<p>
Next: <a href="Formatted-Output-Functions.html#Formatted-Output-Functions" accesskey="n" rel="next">Formatted Output Functions</a>, Previous: <a href="Special-Functions.html#Special-Functions" accesskey="p" rel="prev">Special Functions</a>, Up: <a href="MPFR-Interface.html#MPFR-Interface" accesskey="u" rel="up">MPFR Interface</a> &nbsp; [<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
</div>
</body>
</html>