• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/toolchains/hndtools-armeabi-2013.11/share/doc/arm-arm-none-eabi/html/libquadmath.html/
1<html lang="en">
2<head>
3<title>quadmath_snprintf - GCC libquadmath</title>
4<meta http-equiv="Content-Type" content="text/html">
5<meta name="description" content="GCC libquadmath">
6<meta name="generator" content="makeinfo 4.13">
7<link title="Top" rel="start" href="index.html#Top">
8<link rel="up" href="I_002fO-Library-Routines.html#I_002fO-Library-Routines" title="I/O Library Routines">
9<link rel="prev" href="strtoflt128.html#strtoflt128" title="strtoflt128">
10<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
11<!--
12Copyright (C) 2010-2013 Free Software Foundation, Inc.
13
14     Permission is granted to copy, distribute and/or modify this
15     document under the terms of the GNU Free Documentation License,
16     Version 1.2 or any later version published by the Free Software
17     Foundation; with no Invariant Sections, with the Front-Cover Texts
18     being ``A GNU Manual,'' and with the Back-Cover Texts as in (a)
19     below.  A copy of the license is included in the section entitled
20     ``GNU Free Documentation License.''
21
22     (a) The FSF's Back-Cover Text is: ``You have the freedom to copy
23     and modify this GNU manual.
24   -->
25<meta http-equiv="Content-Style-Type" content="text/css">
26<style type="text/css"><!--
27  pre.display { font-family:inherit }
28  pre.format  { font-family:inherit }
29  pre.smalldisplay { font-family:inherit; font-size:smaller }
30  pre.smallformat  { font-family:inherit; font-size:smaller }
31  pre.smallexample { font-size:smaller }
32  pre.smalllisp    { font-size:smaller }
33  span.sc    { font-variant:small-caps }
34  span.roman { font-family:serif; font-weight:normal; } 
35  span.sansserif { font-family:sans-serif; font-weight:normal; } 
36--></style>
37<link rel="stylesheet" type="text/css" href="../cs.css">
38</head>
39<body>
40<div class="node">
41<a name="quadmath_snprintf"></a>
42<a name="quadmath_005fsnprintf"></a>
43<p>
44Previous:&nbsp;<a rel="previous" accesskey="p" href="strtoflt128.html#strtoflt128">strtoflt128</a>,
45Up:&nbsp;<a rel="up" accesskey="u" href="I_002fO-Library-Routines.html#I_002fO-Library-Routines">I/O Library Routines</a>
46<hr>
47</div>
48
49<h3 class="section">3.2 <code>quadmath_snprintf</code> &mdash; Convert to string</h3>
50
51<p>The function <code>quadmath_snprintf</code> converts a <code>__float128</code> floating-point
52number into a string.  It is a specialized alternative to <code>snprintf</code>, where
53the format string is restricted to a single conversion specifier with <code>Q</code>
54modifier and conversion specifier <code>e</code>, <code>E</code>, <code>f</code>, <code>F</code>, <code>g</code>,
55<code>G</code>, <code>a</code> or <code>A</code>, with no extra characters before or after the
56conversion specifier.  The <code>%m$</code> or <code>*m$</code> style must not be used in
57the format.
58
59     <dl>
60<dt>Syntax<dd><code>int quadmath_snprintf (char *s, size_t size, const char *format, ...)</code>
61
62     <br><dt><em>Arguments</em>:<dd>
63     <p><table summary=""><tr align="left"><td valign="top" width="15%"><var>s</var>    </td><td valign="top" width="70%">output string
64<br></td></tr><tr align="left"><td valign="top" width="15%"><var>size</var> </td><td valign="top" width="70%">byte size of the string, including tailing NUL
65<br></td></tr><tr align="left"><td valign="top" width="15%"><var>format</var> </td><td valign="top" width="70%">conversion specifier string
66     <br></td></tr></table>
67
68     <br><dt>Note<dd>On some targets when supported by the C library hooks are installed
69for <code>printf</code> family of functions, so that <code>printf ("%Qe", 1.2Q);</code>
70etc. works too.
71
72     <br><dt>Example<dd>
73     <pre class="smallexample">          #include &lt;quadmath.h&gt;
74          #include &lt;stdlib.h&gt;
75          #include &lt;stdio.h&gt;
76          
77          int main ()
78          {
79            __float128 r;
80            int prec = 20;
81            int width = 46;
82            char buf[128];
83          
84            r = 2.0q;
85            r = sqrtq (r);
86            int n = quadmath_snprintf (buf, sizeof buf, "%+-#*.20Qe", width, r);
87            if ((size_t) n &lt; sizeof buf)
88              printf ("%s\n", buf);
89              /* Prints: +1.41421356237309504880e+00 */
90            quadmath_snprintf (buf, sizeof buf, "%Qa", r);
91            if ((size_t) n &lt; sizeof buf)
92              printf ("%s\n", buf);
93              /* Prints: 0x1.6a09e667f3bcc908b2fb1366ea96p+0 */
94            n = quadmath_snprintf (NULL, 0, "%+-#46.*Qe", prec, r);
95            if (n &gt; -1)
96              {
97                char *str = malloc (n + 1);
98                if (str)
99                  {
100                    quadmath_snprintf (str, n + 1, "%+-#46.*Qe", prec, r);
101                    printf ("%s\n", str);
102                    /* Prints: +1.41421356237309504880e+00 */
103                  }
104                free (str);
105              }
106            return 0;
107          }
108</pre>
109     </dl>
110
111<!--  -->
112<!-- GNU Free Documentation License -->
113<!--  -->
114<!-- Special handling for inclusion in the install manual. -->
115<!-- man begin DESCRIPTION -->
116   </body></html>
117
118