OSDN Git Service

Daily bump.
[pf3gnuchains/gcc-fork.git] / libquadmath / libquadmath.texi
1 \input texinfo @c -*-texinfo-*-
2
3 @c %**start of header
4 @setfilename libquadmath.info
5 @settitle GCC libquadmath
6 @c %**end of header
7
8 @copying
9 Copyright @copyright{} 2010 Free Software Foundation, Inc.
10
11 @quotation
12 Permission is granted to copy, distribute and/or modify this document
13 under the terms of the GNU Free Documentation License, Version 1.2 or
14 any later version published by the Free Software Foundation; with no
15 Invariant Sections, with the Front-Cover Texts being ``A GNU Manual,''
16 and with the Back-Cover Texts as in (a) below.  A copy of the
17 license is included in the section entitled ``GNU Free Documentation
18 License.''
19
20 (a) The FSF's Back-Cover Text is: ``You have the freedom to
21 copy and modify this GNU manual.
22 @end quotation
23 @end copying
24
25 @ifinfo
26 @dircategory GNU Libraries
27 @direntry
28 * libquadmath: (libquadmath).                  GCC Quad-Precision Math Library
29 @end direntry
30
31 This manual documents the GCC Quad-Precision Math Library API.
32
33 Published by the Free Software Foundation
34 51 Franklin Street, Fifth Floor
35 Boston, MA 02110-1301 USA
36
37 @insertcopying
38 @end ifinfo
39
40
41 @setchapternewpage odd
42
43 @titlepage
44 @title The GCC Quad-Precision Math Library
45 @page
46 @vskip 0pt plus 1filll
47 @comment For the @value{version-GCC} Version*
48 @sp 1
49 Published by the Free Software Foundation @*
50 51 Franklin Street, Fifth Floor@*
51 Boston, MA 02110-1301, USA@*
52 @sp 1
53 @insertcopying
54 @end titlepage
55
56 @summarycontents
57 @contents
58 @page
59
60
61 @node Top
62 @top Introduction
63 @cindex Introduction
64
65 This manual documents the usage of libquadmath, the GCC Quad-Precision
66 Math Library Application Programming Interface (API).
67
68
69 @comment
70 @comment  When you add a new menu item, please keep the right hand
71 @comment  aligned to the same column.  Do not use tabs.  This provides
72 @comment  better formatting.
73 @comment
74 @menu
75 * Typedef and constants::      Defined data types and constants
76 * Math Library Routines::      The Libquadmath math runtime application
77                                programming interface.
78 * I/O Library Routines::       The Libquadmath I/O runtime application
79                                programming interface.
80 * GNU Free Documentation License::
81                                How you can copy and share this manual.
82 * Reporting Bugs::             How to report bugs in GCC Libquadmath.
83 @c * Index::                      Index of this documentation.
84 @end menu
85
86
87 @c ---------------------------------------------------------------------
88 @c Defined macros
89 @c ---------------------------------------------------------------------
90
91 @node Typedef and constants
92 @chapter Typedef and constants
93
94 The following data type has been defined via @code{typedef}.
95
96 @table @asis
97 @item @code{__complex128}: @code{__float128}-based complex number
98 @end table
99
100 The following macros are defined, which give the numeric limits of the
101 @code{__float128} data type.
102
103 @table @asis
104 @item @code{FLT128_MAX}: largest finite number
105 @item @code{FLT128_MIN}: smallest positive number with full precision
106 @item @code{FLT128_EPSILON}: difference between 1 and the next larger
107                              representable number
108 @item @code{FLT128_DENORM_MIN}: smallest positive denormalized number
109 @item @code{FLT128_MANT_DIG}: number of digits in the mantissa (bit precision)
110 @item @code{FLT128_MIN_EXP}: maximal negative exponent
111 @item @code{FLT128_MAX_EXP}: maximal positive exponent
112 @item @code{FLT128_DIG}: number of decimal digits in the mantissa
113 @item @code{FLT128_MIN_10_EXP}: maximal negative decimal exponent
114 @item @code{FLT128_MAX_10_EXP}: maximal positive decimal exponent
115 @end table
116
117 The following mathematical constants of type @code{__float128} are defined.
118
119 @table @asis
120 @item @code{M_Eq}: the constant e (Euler's number)
121 @item @code{M_LOG2Eq}: binary logarithm of 2
122 @item @code{M_LOG10Eq}: common, decimal logarithm of 2
123 @item @code{M_LN2q}: natural logarithm of 2
124 @item @code{M_LN10q}: natural logarithm of 10
125 @item @code{M_PIq}: pi
126 @item @code{M_PI_2q}: pi divided by two
127 @item @code{M_PI_4q}: pi divided by four
128 @item @code{M_1_PIq}: one over pi
129 @item @code{M_2_PIq}: one over two pi
130 @item @code{M_2_SQRTPIq}: two over square root of pi
131 @item @code{M_SQRT2q}: square root of 2
132 @item @code{M_SQRT1_2q}: one over square root of 2
133 @end table
134
135
136 @c ---------------------------------------------------------------------
137 @c Math routines
138 @c ---------------------------------------------------------------------
139
140 @node Math Library Routines
141 @chapter Math Library Routines
142
143 The following mathematical functions are available:
144
145 @table @asis
146 @item @code{acosq}: arc cosine function
147 @item @code{acoshq}: inverse hyperbolic cosine function
148 @item @code{asinq}: arc sine function
149 @item @code{asinhq}: inverse hyperbolic sine function
150 @item @code{atanq}: arc tangent function
151 @item @code{atanhq}: inverse hyperbolic tangent function
152 @item @code{atan2q}: arc tangent function
153 @item @code{cbrtq}: cube root function
154 @item @code{ceilq}: ceiling value function
155 @item @code{copysignq}: copy sign of a number
156 @item @code{coshq}: hyperbolic cosine function
157 @item @code{cosq}: cosine function
158 @item @code{erfq}: error function
159 @item @code{erfcq}: complementary error function
160 @item @code{expq}: exponential function
161 @item @code{expm1q}: exponential minus 1 function
162 @need 800
163 @item @code{fabsq}: absolute value function
164 @item @code{fdimq}: positive difference function
165 @item @code{finiteq}: check finiteness of value
166 @item @code{floorq}: floor value function
167 @item @code{fmaq}: fused multiply and add
168 @item @code{fmaxq}: determine maximum of two values
169 @item @code{fminq}: determine minimum of two values
170 @item @code{fmodq}: remainder value function
171 @item @code{frexpq}: extract mantissa and exponent
172 @item @code{hypotq}: Eucledian distance function
173 @item @code{ilogbq}: get exponent of the value
174 @item @code{isinfq}: check for infinity
175 @item @code{isnanq}: check for not a number
176 @item @code{j0q}: Bessel function of the first kind, first order
177 @item @code{j1q}: Bessel function of the first kind, second order
178 @item @code{jnq}: Bessel function of the first kind, @var{n}-th order
179 @item @code{ldexpq}: load exponent of the value
180 @item @code{lgammaq}: logarithmic gamma function
181 @item @code{llrintq}: round to nearest integer value
182 @item @code{llroundq}: round to nearest integer value away from zero
183 @item @code{logq}: natural logarithm function
184 @item @code{log10q}: base 10 logarithm function
185 @item @code{log1pq}: compute natural logarithm of the value plus one
186 @item @code{log2q}: base 2 logarithm function
187 @need 800
188 @item @code{lrintq}: round to nearest integer value
189 @item @code{lroundq}: round to nearest integer value away from zero
190 @item @code{modfq}: decompose the floating-point number
191 @item @code{nanq}: return quiet NaN
192 @item @code{nearbyintq}: round to nearest integer
193 @item @code{nextafterq}: next representable floating-point number
194 @item @code{powq}: power function
195 @item @code{remainderq}: remainder function
196 @item @code{remquoq}: remainder and part of quotient
197 @item @code{rintq}: round-to-nearest integral value
198 @item @code{roundq}: round-to-nearest integral value, return @code{__float128}
199 @item @code{scalblnq}: compute exponent using @code{FLT_RADIX}
200 @item @code{scalbnq}: compute exponent using @code{FLT_RADIX}
201 @item @code{signbitq}: return sign bit
202 @item @code{sincosq}: calculate sine and cosine simulataneously
203 @item @code{sinhq}: hyperbolic sine function
204 @item @code{sinq}: sine function
205 @item @code{sqrtq}: square root function
206 @item @code{tanq}: tangent function
207 @item @code{tanhq}: hyperbolic tangent function
208 @need 800
209 @item @code{tgammaq}: true gamma function
210 @item @code{truncq}: round to integer, towards zero
211 @item @code{y0q}: Bessel function of the second kind, first order
212 @item @code{y1q}: Bessel function of the second kind, second order
213 @item @code{ynq}: Bessel function of the second kind, @var{n}-th order
214 @item @code{cabsq} complex absolute value function
215 @item @code{cargq}: calculate the argument
216 @item @code{cimagq} imaginary part of complex number
217 @item @code{crealq}: real part of complex number
218 @item @code{cacoshq}: complex arc hyperbolic cosine function
219 @item @code{cacosq}: complex arc cosine function
220 @item @code{casinhq}: complex arc hyperbolic sine function
221 @item @code{casinq}: complex arc sine function
222 @item @code{catanhq}: complex arc hyperbolic tangent function
223 @item @code{catanq}: complex arc tangent function
224 @item @code{ccosq} complex cosine function:
225 @item @code{ccoshq}: complex hyperbolic cosine function
226 @item @code{cexpq}: complex exponential function
227 @need 800
228 @item @code{cexpiq}: computes the exponential function of ``i'' times a
229                      real value
230 @item @code{clogq}: complex natural logarithm
231 @item @code{clog10q}: complex base 10 logarithm
232 @item @code{conjq}: complex conjugate function
233 @item @code{cpowq}: complex power function
234 @item @code{cprojq}: project into Riemann Sphere
235 @item @code{csinq}: complex sine function
236 @item @code{csinhq}: complex hyperbolic sine function
237 @item @code{csqrtq}: complex square root
238 @item @code{ctanq}: complex tangent function
239 @item @code{ctanhq}: complex hyperbolic tangent function
240 @end table
241
242
243 @c ---------------------------------------------------------------------
244 @c I/O routines
245 @c ---------------------------------------------------------------------
246
247 @node I/O Library Routines
248 @chapter I/O Library Routines
249
250 @menu
251 * @code{strtoflt128}:          strtoflt128,          Convert from string
252 * @code{quadmath_snprintf}:    quadmath_snprintf,    Convert to string
253 @end menu
254
255
256 @node strtoflt128
257 @section @code{strtoflt128} --- Convert from string
258
259 The function @code{strtoflt128} converts a string into a
260 @code{__float128} number.
261
262 @table @asis
263 @item Syntax
264 @code{__float128 strtoflt128 (const char *s, char **sp)}
265
266 @item @emph{Arguments}:
267 @multitable @columnfractions .15 .70
268 @item @var{s}  @tab input string
269 @item @var{sp} @tab the address of the next character in the string
270 @end multitable
271
272 The argument @var{sp} contains, if not @code{NULL}, the address of the
273 next character following the parts of the string, which have been read.
274
275 @item Example
276 @smallexample
277 #include <quadmath.h>
278
279 int main ()
280 @{
281   __float128 r;
282
283   r = strtoflt128 ("1.2345678", NULL);
284
285   return 0;
286 @}
287 @end smallexample
288 @end table
289
290
291 @node quadmath_snprintf
292 @section @code{quadmath_snprintf} --- Convert to string
293
294 The function @code{quadmath_snprintf} converts a @code{__float128} floating-point
295 number into a string.  It is a specialized alternative to @code{snprintf}, where
296 the format string is restricted to a single conversion specifier with @code{Q}
297 modifier and conversion specifier @code{e}, @code{E}, @code{f}, @code{F}, @code{g},
298 @code{G}, @code{a} or @code{A}, with no extra characters before or after the
299 conversion specifier.  The @code{%m$} or @code{*m$} style must not be used in
300 the format.
301
302 @table @asis
303 @item Syntax
304 @code{int quadmath_snprintf (char *s, size_t size, const char *format, ...)}
305
306 @item @emph{Arguments}:
307 @multitable @columnfractions .15 .70
308 @item @var{s}    @tab output string
309 @item @var{size} @tab byte size of the string, including tailing NUL
310 @item @var{format} @tab conversion specifier string
311 @end multitable
312
313 @item Note
314 On some targets when supported by the C library hooks are installed
315 for @code{printf} family of functions, so that @code{printf ("%Qe", 1.2Q);}
316 etc.@: works too.
317
318 @item Example
319 @smallexample
320 #include <quadmath.h>
321 #include <stdlib.h>
322 #include <stdio.h>
323
324 int main ()
325 @{
326   __float128 r;
327   int prec = 20;
328   int width = 46;
329   char buf[128];
330
331   r = 2.0q;
332   r = sqrtq (r);
333   int n = quadmath_snprintf (buf, sizeof buf, "%+-#*.20Qe", width, r);
334   if ((size_t) n < sizeof buf)
335     printf ("%s\n", buf);
336     /* Prints: +1.41421356237309504880e+00 */
337   quadmath_snprintf (buf, sizeof buf, "%Qa", r);
338   if ((size_t) n < sizeof buf)
339     printf ("%s\n", buf);
340     /* Prints: 0x1.6a09e667f3bcc908b2fb1366ea96p+0 */
341   n = quadmath_snprintf (NULL, 0, "%+-#46.*Qe", prec, r);
342   if (n > -1)
343     @{
344       char *str = malloc (n + 1);
345       if (str)
346         @{
347           quadmath_snprintf (str, n + 1, "%+-#46.*Qe", prec, r);
348           printf ("%s\n", str);
349           /* Prints: +1.41421356237309504880e+00 */
350         @}
351       free (str);
352     @}
353   return 0;
354 @}
355 @end smallexample
356
357 @end table
358
359
360 @c ---------------------------------------------------------------------
361 @c GNU Free Documentation License
362 @c ---------------------------------------------------------------------
363
364 @include fdl.texi
365
366 @c ---------------------------------------------------------------------
367 @c Reporting Bugs
368 @c ---------------------------------------------------------------------
369
370 @c For BUGURL
371 @include libquadmath-vers.texi
372
373 @node Reporting Bugs
374 @chapter Reporting Bugs
375
376 Bugs in the GCC Quad-Precision Math Library implementation should be
377 reported via @value{BUGURL}.
378
379
380 @c ---------------------------------------------------------------------
381 @c Index
382 @c ---------------------------------------------------------------------
383
384 @c @node Index
385 @c @unnumbered Index
386 @c 
387 @c @printindex cp
388
389 @bye