Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > b38d2da330d1936e5ab1307c039c4941 > files > 392

octave-doc-3.6.4-3.mga4.noarch.rpm

<html lang="en">
<head>
<title>Output Conversion Syntax - GNU Octave</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="GNU Octave">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="C_002dStyle-I_002fO-Functions.html#C_002dStyle-I_002fO-Functions" title="C-Style I/O Functions">
<link rel="prev" href="Output-Conversion-for-Matrices.html#Output-Conversion-for-Matrices" title="Output Conversion for Matrices">
<link rel="next" href="Table-of-Output-Conversions.html#Table-of-Output-Conversions" title="Table of Output Conversions">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
  pre.display { font-family:inherit }
  pre.format  { font-family:inherit }
  pre.smalldisplay { font-family:inherit; font-size:smaller }
  pre.smallformat  { font-family:inherit; font-size:smaller }
  pre.smallexample { font-size:smaller }
  pre.smalllisp    { font-size:smaller }
  span.sc    { font-variant:small-caps }
  span.roman { font-family:serif; font-weight:normal; } 
  span.sansserif { font-family:sans-serif; font-weight:normal; } 
--></style>
</head>
<body>
<div class="node">
<a name="Output-Conversion-Syntax"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="Table-of-Output-Conversions.html#Table-of-Output-Conversions">Table of Output Conversions</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="Output-Conversion-for-Matrices.html#Output-Conversion-for-Matrices">Output Conversion for Matrices</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="C_002dStyle-I_002fO-Functions.html#C_002dStyle-I_002fO-Functions">C-Style I/O Functions</a>
<hr>
</div>

<h4 class="subsection">14.2.6 Output Conversion Syntax</h4>

<p>This section provides details about the precise syntax of conversion
specifications that can appear in a <code>printf</code> template
string.

   <p>Characters in the template string that are not part of a
conversion specification are printed as-is to the output stream.

   <p>The conversion specifications in a <code>printf</code> template string have
the general form:

<pre class="example">     % <var>flags</var> <var>width</var> <span class="roman">[</span> . <var>precision</var> <span class="roman">]</span> <var>type</var> <var>conversion</var>
</pre>
   <p>For example, in the conversion specifier &lsquo;<samp><span class="samp">%-10.8ld</span></samp>&rsquo;, the &lsquo;<samp><span class="samp">-</span></samp>&rsquo;
is a flag, &lsquo;<samp><span class="samp">10</span></samp>&rsquo; specifies the field width, the precision is
&lsquo;<samp><span class="samp">8</span></samp>&rsquo;, the letter &lsquo;<samp><span class="samp">l</span></samp>&rsquo; is a type modifier, and &lsquo;<samp><span class="samp">d</span></samp>&rsquo; specifies
the conversion style.  (This particular type specifier says to print a
numeric argument in decimal notation, with a minimum of 8 digits
left-justified in a field at least 10 characters wide.)

   <p>In more detail, output conversion specifications consist of an
initial &lsquo;<samp><span class="samp">%</span></samp>&rsquo; character followed in sequence by:

     <ul>
<li>Zero or more <dfn>flag characters</dfn> that modify the normal behavior of
the conversion specification. 
<a name="index-flag-character-_0028_0040code_007bprintf_007d_0029-992"></a>
<li>An optional decimal integer specifying the <dfn>minimum field width</dfn>. 
If the normal conversion produces fewer characters than this, the field
is padded with spaces to the specified width.  This is a <em>minimum</em>
value; if the normal conversion produces more characters than this, the
field is <em>not</em> truncated.  Normally, the output is right-justified
within the field. 
<a name="index-minimum-field-width-_0028_0040code_007bprintf_007d_0029-993"></a>
You can also specify a field width of &lsquo;<samp><span class="samp">*</span></samp>&rsquo;.  This means that the
next argument in the argument list (before the actual value to be
printed) is used as the field width.  The value is rounded to the
nearest integer.  If the value is negative, this means to set the
&lsquo;<samp><span class="samp">-</span></samp>&rsquo; flag (see below) and to use the absolute value as the field
width.

     <li>An optional <dfn>precision</dfn> to specify the number of digits to be
written for the numeric conversions.  If the precision is specified, it
consists of a period (&lsquo;<samp><span class="samp">.</span></samp>&rsquo;) followed optionally by a decimal integer
(which defaults to zero if omitted). 
<a name="index-precision-_0028_0040code_007bprintf_007d_0029-994"></a>
You can also specify a precision of &lsquo;<samp><span class="samp">*</span></samp>&rsquo;.  This means that the next
argument in the argument list (before the actual value to be printed) is
used as the precision.  The value must be an integer, and is ignored
if it is negative.

     <li>An optional <dfn>type modifier character</dfn>.  This character is ignored by
Octave's <code>printf</code> function, but is recognized to provide
compatibility with the C language <code>printf</code>.

     <li>A character that specifies the conversion to be applied. 
</ul>

   <p>The exact options that are permitted and how they are interpreted vary
between the different conversion specifiers.  See the descriptions of the
individual conversions for information about the particular options that
they use.

   </body></html>