Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 3e60ff9d4d6f58c8fbd17208f14089fa > files > 192

octave-doc-3.2.3-3mdv2010.0.i586.rpm

<html lang="en">
<head>
<title>Floating-Point Conversions - Untitled</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Untitled">
<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="Integer-Conversions.html#Integer-Conversions" title="Integer Conversions">
<link rel="next" href="Other-Output-Conversions.html#Other-Output-Conversions" title="Other 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="Floating-Point-Conversions"></a>
<a name="Floating_002dPoint-Conversions"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="Other-Output-Conversions.html#Other-Output-Conversions">Other Output Conversions</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="Integer-Conversions.html#Integer-Conversions">Integer Conversions</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.9 Floating-Point Conversions</h4>

<p>This section discusses the conversion specifications for floating-point
numbers: the &lsquo;<samp><span class="samp">%f</span></samp>&rsquo;, &lsquo;<samp><span class="samp">%e</span></samp>&rsquo;, &lsquo;<samp><span class="samp">%E</span></samp>&rsquo;, &lsquo;<samp><span class="samp">%g</span></samp>&rsquo;, and &lsquo;<samp><span class="samp">%G</span></samp>&rsquo;
conversions.

   <p>The &lsquo;<samp><span class="samp">%f</span></samp>&rsquo; conversion prints its argument in fixed-point notation,
producing output of the form
[<code>-</code>]<var>ddd</var><code>.</code><var>ddd</var><!-- /@w -->,
where the number of digits following the decimal point is controlled
by the precision you specify.

   <p>The &lsquo;<samp><span class="samp">%e</span></samp>&rsquo; conversion prints its argument in exponential notation,
producing output of the form
[<code>-</code>]<var>d</var><code>.</code><var>ddd</var><code>e</code>[<code>+</code>|<code>-</code>]<var>dd</var><!-- /@w -->. 
Again, the number of digits following the decimal point is controlled by
the precision.  The exponent always contains at least two digits.  The
&lsquo;<samp><span class="samp">%E</span></samp>&rsquo; conversion is similar but the exponent is marked with the letter
&lsquo;<samp><span class="samp">E</span></samp>&rsquo; instead of &lsquo;<samp><span class="samp">e</span></samp>&rsquo;.

   <p>The &lsquo;<samp><span class="samp">%g</span></samp>&rsquo; and &lsquo;<samp><span class="samp">%G</span></samp>&rsquo; conversions print the argument in the style
of &lsquo;<samp><span class="samp">%e</span></samp>&rsquo; or &lsquo;<samp><span class="samp">%E</span></samp>&rsquo; (respectively) if the exponent would be less
than -4 or greater than or equal to the precision; otherwise they use the
&lsquo;<samp><span class="samp">%f</span></samp>&rsquo; style.  Trailing zeros are removed from the fractional portion
of the result and a decimal-point character appears only if it is
followed by a digit.

   <p>The following flags can be used to modify the behavior:

<!-- Not @samp so we can have ` ' as an item. -->
     <dl>
<dt>&lsquo;<samp><span class="samp">-</span></samp>&rsquo;<dd>Left-justify the result in the field.  Normally the result is
right-justified.

     <br><dt>&lsquo;<samp><span class="samp">+</span></samp>&rsquo;<dd>Always include a plus or minus sign in the result.

     <br><dt>&lsquo;<samp> </samp>&rsquo;<dd>If the result doesn't start with a plus or minus sign, prefix it with a
space instead.  Since the &lsquo;<samp><span class="samp">+</span></samp>&rsquo; flag ensures that the result includes
a sign, this flag is ignored if you supply both of them.

     <br><dt>&lsquo;<samp><span class="samp">#</span></samp>&rsquo;<dd>Specifies that the result should always include a decimal point, even
if no digits follow it.  For the &lsquo;<samp><span class="samp">%g</span></samp>&rsquo; and &lsquo;<samp><span class="samp">%G</span></samp>&rsquo; conversions,
this also forces trailing zeros after the decimal point to be left
in place where they would otherwise be removed.

     <br><dt>&lsquo;<samp><span class="samp">0</span></samp>&rsquo;<dd>Pad the field with zeros instead of spaces; the zeros are placed
after any sign.  This flag is ignored if the &lsquo;<samp><span class="samp">-</span></samp>&rsquo; flag is also
specified. 
</dl>

   <p>The precision specifies how many digits follow the decimal-point
character for the &lsquo;<samp><span class="samp">%f</span></samp>&rsquo;, &lsquo;<samp><span class="samp">%e</span></samp>&rsquo;, and &lsquo;<samp><span class="samp">%E</span></samp>&rsquo; conversions.  For
these conversions, the default precision is <code>6</code>.  If the precision
is explicitly <code>0</code>, this suppresses the decimal point character
entirely.  For the &lsquo;<samp><span class="samp">%g</span></samp>&rsquo; and &lsquo;<samp><span class="samp">%G</span></samp>&rsquo; conversions, the precision
specifies how many significant digits to print.  Significant digits are
the first digit before the decimal point, and all the digits after it. 
If the precision is <code>0</code> or not specified for &lsquo;<samp><span class="samp">%g</span></samp>&rsquo; or
&lsquo;<samp><span class="samp">%G</span></samp>&rsquo;, it is treated like a value of <code>1</code>.  If the value being
printed cannot be expressed precisely in the specified number of digits,
the value is rounded to the nearest number that fits.

   </body></html>