1181254a7Smrg\input texinfo @c -*-texinfo-*- 2181254a7Smrg 3181254a7Smrg@c %**start of header 4181254a7Smrg@setfilename libquadmath.info 5181254a7Smrg@settitle GCC libquadmath 6181254a7Smrg@c %**end of header 7181254a7Smrg 8181254a7Smrg@copying 9*b1e83836SmrgCopyright @copyright{} 2010-2022 Free Software Foundation, Inc. 10181254a7Smrg 11181254a7Smrg@quotation 12181254a7SmrgPermission is granted to copy, distribute and/or modify this document 13181254a7Smrgunder the terms of the GNU Free Documentation License, Version 1.2 or 14181254a7Smrgany later version published by the Free Software Foundation; with no 15181254a7SmrgInvariant Sections, with the Front-Cover Texts being ``A GNU Manual,'' 16181254a7Smrgand with the Back-Cover Texts as in (a) below. A copy of the 17181254a7Smrglicense is included in the section entitled ``GNU Free Documentation 18181254a7SmrgLicense.'' 19181254a7Smrg 20181254a7Smrg(a) The FSF's Back-Cover Text is: ``You have the freedom to 21181254a7Smrgcopy and modify this GNU manual. 22181254a7Smrg@end quotation 23181254a7Smrg@end copying 24181254a7Smrg 25181254a7Smrg@ifinfo 26181254a7Smrg@dircategory GNU Libraries 27181254a7Smrg@direntry 28181254a7Smrg* libquadmath: (libquadmath). GCC Quad-Precision Math Library 29181254a7Smrg@end direntry 30181254a7Smrg 31181254a7SmrgThis manual documents the GCC Quad-Precision Math Library API. 32181254a7Smrg 33181254a7SmrgPublished by the Free Software Foundation 34181254a7Smrg51 Franklin Street, Fifth Floor 35181254a7SmrgBoston, MA 02110-1301 USA 36181254a7Smrg 37181254a7Smrg@insertcopying 38181254a7Smrg@end ifinfo 39181254a7Smrg 40181254a7Smrg 41181254a7Smrg@setchapternewpage odd 42181254a7Smrg 43181254a7Smrg@titlepage 44181254a7Smrg@title The GCC Quad-Precision Math Library 45181254a7Smrg@page 46181254a7Smrg@vskip 0pt plus 1filll 47181254a7Smrg@comment For the @value{version-GCC} Version* 48181254a7Smrg@sp 1 49181254a7SmrgPublished by the Free Software Foundation @* 50181254a7Smrg51 Franklin Street, Fifth Floor@* 51181254a7SmrgBoston, MA 02110-1301, USA@* 52181254a7Smrg@sp 1 53181254a7Smrg@insertcopying 54181254a7Smrg@end titlepage 55181254a7Smrg 56181254a7Smrg@summarycontents 57181254a7Smrg@contents 58181254a7Smrg@page 59181254a7Smrg 60181254a7Smrg 61181254a7Smrg@node Top 62181254a7Smrg@top Introduction 63181254a7Smrg@cindex Introduction 64181254a7Smrg 65181254a7SmrgThis manual documents the usage of libquadmath, the GCC Quad-Precision 66181254a7SmrgMath Library Application Programming Interface (API). 67181254a7Smrg 68181254a7Smrg 69181254a7Smrg@comment 70181254a7Smrg@comment When you add a new menu item, please keep the right hand 71181254a7Smrg@comment aligned to the same column. Do not use tabs. This provides 72181254a7Smrg@comment better formatting. 73181254a7Smrg@comment 74181254a7Smrg@menu 75181254a7Smrg* Typedef and constants:: Defined data types and constants 76181254a7Smrg* Math Library Routines:: The Libquadmath math runtime application 77181254a7Smrg programming interface. 78181254a7Smrg* I/O Library Routines:: The Libquadmath I/O runtime application 79181254a7Smrg programming interface. 80181254a7Smrg* GNU Free Documentation License:: 81181254a7Smrg How you can copy and share this manual. 82181254a7Smrg* Reporting Bugs:: How to report bugs in GCC Libquadmath. 83181254a7Smrg@c * Index:: Index of this documentation. 84181254a7Smrg@end menu 85181254a7Smrg 86181254a7Smrg 87181254a7Smrg@c --------------------------------------------------------------------- 88181254a7Smrg@c Defined macros 89181254a7Smrg@c --------------------------------------------------------------------- 90181254a7Smrg 91181254a7Smrg@node Typedef and constants 92181254a7Smrg@chapter Typedef and constants 93181254a7Smrg 94181254a7SmrgThe following data type has been defined via @code{typedef}. 95181254a7Smrg 96181254a7Smrg@table @asis 97181254a7Smrg@item @code{__complex128}: @code{__float128}-based complex number 98181254a7Smrg@end table 99181254a7Smrg 100181254a7SmrgThe following macros are defined, which give the numeric limits of the 101181254a7Smrg@code{__float128} data type. 102181254a7Smrg 103181254a7Smrg@table @asis 104181254a7Smrg@item @code{FLT128_MAX}: largest finite number 105181254a7Smrg@item @code{FLT128_MIN}: smallest positive number with full precision 106181254a7Smrg@item @code{FLT128_EPSILON}: difference between 1 and the next larger 107181254a7Smrg representable number 108181254a7Smrg@item @code{FLT128_DENORM_MIN}: smallest positive denormalized number 109181254a7Smrg@item @code{FLT128_MANT_DIG}: number of digits in the mantissa (bit precision) 110181254a7Smrg@item @code{FLT128_MIN_EXP}: maximal negative exponent 111181254a7Smrg@item @code{FLT128_MAX_EXP}: maximal positive exponent 112181254a7Smrg@item @code{FLT128_DIG}: number of decimal digits in the mantissa 113181254a7Smrg@item @code{FLT128_MIN_10_EXP}: maximal negative decimal exponent 114181254a7Smrg@item @code{FLT128_MAX_10_EXP}: maximal positive decimal exponent 115181254a7Smrg@end table 116181254a7Smrg 117181254a7SmrgThe following mathematical constants of type @code{__float128} are defined. 118181254a7Smrg 119181254a7Smrg@table @asis 120181254a7Smrg@item @code{M_Eq}: the constant e (Euler's number) 121181254a7Smrg@item @code{M_LOG2Eq}: binary logarithm of 2 122181254a7Smrg@item @code{M_LOG10Eq}: common, decimal logarithm of 2 123181254a7Smrg@item @code{M_LN2q}: natural logarithm of 2 124181254a7Smrg@item @code{M_LN10q}: natural logarithm of 10 125181254a7Smrg@item @code{M_PIq}: pi 126181254a7Smrg@item @code{M_PI_2q}: pi divided by two 127181254a7Smrg@item @code{M_PI_4q}: pi divided by four 128181254a7Smrg@item @code{M_1_PIq}: one over pi 129181254a7Smrg@item @code{M_2_PIq}: one over two pi 130181254a7Smrg@item @code{M_2_SQRTPIq}: two over square root of pi 131181254a7Smrg@item @code{M_SQRT2q}: square root of 2 132181254a7Smrg@item @code{M_SQRT1_2q}: one over square root of 2 133181254a7Smrg@end table 134181254a7Smrg 135181254a7Smrg 136181254a7Smrg@c --------------------------------------------------------------------- 137181254a7Smrg@c Math routines 138181254a7Smrg@c --------------------------------------------------------------------- 139181254a7Smrg 140181254a7Smrg@node Math Library Routines 141181254a7Smrg@chapter Math Library Routines 142181254a7Smrg 143181254a7SmrgThe following mathematical functions are available: 144181254a7Smrg 145181254a7Smrg@table @asis 146181254a7Smrg@item @code{acosq}: arc cosine function 147181254a7Smrg@item @code{acoshq}: inverse hyperbolic cosine function 148181254a7Smrg@item @code{asinq}: arc sine function 149181254a7Smrg@item @code{asinhq}: inverse hyperbolic sine function 150181254a7Smrg@item @code{atanq}: arc tangent function 151181254a7Smrg@item @code{atanhq}: inverse hyperbolic tangent function 152181254a7Smrg@item @code{atan2q}: arc tangent function 153181254a7Smrg@item @code{cbrtq}: cube root function 154181254a7Smrg@item @code{ceilq}: ceiling value function 155181254a7Smrg@item @code{copysignq}: copy sign of a number 156181254a7Smrg@item @code{coshq}: hyperbolic cosine function 157181254a7Smrg@item @code{cosq}: cosine function 158181254a7Smrg@item @code{erfq}: error function 159181254a7Smrg@item @code{erfcq}: complementary error function 160181254a7Smrg@item @code{exp2q}: base 2 exponential function 161181254a7Smrg@item @code{expq}: exponential function 162181254a7Smrg@item @code{expm1q}: exponential minus 1 function 163181254a7Smrg@need 800 164181254a7Smrg@item @code{fabsq}: absolute value function 165181254a7Smrg@item @code{fdimq}: positive difference function 166181254a7Smrg@item @code{finiteq}: check finiteness of value 167181254a7Smrg@item @code{floorq}: floor value function 168181254a7Smrg@item @code{fmaq}: fused multiply and add 169181254a7Smrg@item @code{fmaxq}: determine maximum of two values 170181254a7Smrg@item @code{fminq}: determine minimum of two values 171181254a7Smrg@item @code{fmodq}: remainder value function 172181254a7Smrg@item @code{frexpq}: extract mantissa and exponent 173181254a7Smrg@item @code{hypotq}: Eucledian distance function 174181254a7Smrg@item @code{ilogbq}: get exponent of the value 175181254a7Smrg@item @code{isinfq}: check for infinity 176181254a7Smrg@item @code{isnanq}: check for not a number 177181254a7Smrg@item @code{issignalingq}: check for signaling not a number 178181254a7Smrg@item @code{j0q}: Bessel function of the first kind, first order 179181254a7Smrg@item @code{j1q}: Bessel function of the first kind, second order 180181254a7Smrg@item @code{jnq}: Bessel function of the first kind, @var{n}-th order 181181254a7Smrg@item @code{ldexpq}: load exponent of the value 182181254a7Smrg@item @code{lgammaq}: logarithmic gamma function 183181254a7Smrg@item @code{llrintq}: round to nearest integer value 184181254a7Smrg@item @code{llroundq}: round to nearest integer value away from zero 185181254a7Smrg@item @code{logbq}: get exponent of the value 186181254a7Smrg@item @code{logq}: natural logarithm function 187181254a7Smrg@item @code{log10q}: base 10 logarithm function 188181254a7Smrg@item @code{log1pq}: compute natural logarithm of the value plus one 189181254a7Smrg@item @code{log2q}: base 2 logarithm function 190181254a7Smrg@need 800 191181254a7Smrg@item @code{lrintq}: round to nearest integer value 192181254a7Smrg@item @code{lroundq}: round to nearest integer value away from zero 193181254a7Smrg@item @code{modfq}: decompose the floating-point number 194181254a7Smrg@item @code{nanq}: return quiet NaN 195181254a7Smrg@item @code{nearbyintq}: round to nearest integer 196181254a7Smrg@item @code{nextafterq}: next representable floating-point number 197181254a7Smrg@item @code{powq}: power function 198181254a7Smrg@item @code{remainderq}: remainder function 199181254a7Smrg@item @code{remquoq}: remainder and part of quotient 200181254a7Smrg@item @code{rintq}: round-to-nearest integral value 201181254a7Smrg@item @code{roundq}: round-to-nearest integral value, return @code{__float128} 202181254a7Smrg@item @code{scalblnq}: compute exponent using @code{FLT_RADIX} 203181254a7Smrg@item @code{scalbnq}: compute exponent using @code{FLT_RADIX} 204181254a7Smrg@item @code{signbitq}: return sign bit 205181254a7Smrg@item @code{sincosq}: calculate sine and cosine simultaneously 206181254a7Smrg@item @code{sinhq}: hyperbolic sine function 207181254a7Smrg@item @code{sinq}: sine function 208181254a7Smrg@item @code{sqrtq}: square root function 209181254a7Smrg@item @code{tanq}: tangent function 210181254a7Smrg@item @code{tanhq}: hyperbolic tangent function 211181254a7Smrg@need 800 212181254a7Smrg@item @code{tgammaq}: true gamma function 213181254a7Smrg@item @code{truncq}: round to integer, towards zero 214181254a7Smrg@item @code{y0q}: Bessel function of the second kind, first order 215181254a7Smrg@item @code{y1q}: Bessel function of the second kind, second order 216181254a7Smrg@item @code{ynq}: Bessel function of the second kind, @var{n}-th order 217181254a7Smrg@item @code{cabsq} complex absolute value function 218181254a7Smrg@item @code{cargq}: calculate the argument 219181254a7Smrg@item @code{cimagq} imaginary part of complex number 220181254a7Smrg@item @code{crealq}: real part of complex number 221181254a7Smrg@item @code{cacoshq}: complex arc hyperbolic cosine function 222181254a7Smrg@item @code{cacosq}: complex arc cosine function 223181254a7Smrg@item @code{casinhq}: complex arc hyperbolic sine function 224181254a7Smrg@item @code{casinq}: complex arc sine function 225181254a7Smrg@item @code{catanhq}: complex arc hyperbolic tangent function 226181254a7Smrg@item @code{catanq}: complex arc tangent function 227181254a7Smrg@item @code{ccosq} complex cosine function: 228181254a7Smrg@item @code{ccoshq}: complex hyperbolic cosine function 229181254a7Smrg@item @code{cexpq}: complex exponential function 230181254a7Smrg@need 800 231181254a7Smrg@item @code{cexpiq}: computes the exponential function of ``i'' times a 232181254a7Smrg real value 233181254a7Smrg@item @code{clogq}: complex natural logarithm 234181254a7Smrg@item @code{clog10q}: complex base 10 logarithm 235181254a7Smrg@item @code{conjq}: complex conjugate function 236181254a7Smrg@item @code{cpowq}: complex power function 237181254a7Smrg@item @code{cprojq}: project into Riemann Sphere 238181254a7Smrg@item @code{csinq}: complex sine function 239181254a7Smrg@item @code{csinhq}: complex hyperbolic sine function 240181254a7Smrg@item @code{csqrtq}: complex square root 241181254a7Smrg@item @code{ctanq}: complex tangent function 242181254a7Smrg@item @code{ctanhq}: complex hyperbolic tangent function 243181254a7Smrg@end table 244181254a7Smrg 245181254a7Smrg 246181254a7Smrg@c --------------------------------------------------------------------- 247181254a7Smrg@c I/O routines 248181254a7Smrg@c --------------------------------------------------------------------- 249181254a7Smrg 250181254a7Smrg@node I/O Library Routines 251181254a7Smrg@chapter I/O Library Routines 252181254a7Smrg 253181254a7Smrg@menu 254181254a7Smrg* @code{strtoflt128}: strtoflt128, Convert from string 255181254a7Smrg* @code{quadmath_snprintf}: quadmath_snprintf, Convert to string 256181254a7Smrg@end menu 257181254a7Smrg 258181254a7Smrg 259181254a7Smrg@node strtoflt128 260181254a7Smrg@section @code{strtoflt128} --- Convert from string 261181254a7Smrg 262181254a7SmrgThe function @code{strtoflt128} converts a string into a 263181254a7Smrg@code{__float128} number. 264181254a7Smrg 265181254a7Smrg@table @asis 266181254a7Smrg@item Syntax 267181254a7Smrg@code{__float128 strtoflt128 (const char *s, char **sp)} 268181254a7Smrg 269181254a7Smrg@item @emph{Arguments}: 270181254a7Smrg@multitable @columnfractions .15 .70 271181254a7Smrg@item @var{s} @tab input string 272181254a7Smrg@item @var{sp} @tab the address of the next character in the string 273181254a7Smrg@end multitable 274181254a7Smrg 275181254a7SmrgThe argument @var{sp} contains, if not @code{NULL}, the address of the 276181254a7Smrgnext character following the parts of the string, which have been read. 277181254a7Smrg 278181254a7Smrg@item Example 279181254a7Smrg@smallexample 280181254a7Smrg#include <quadmath.h> 281181254a7Smrg 282181254a7Smrgint main () 283181254a7Smrg@{ 284181254a7Smrg __float128 r; 285181254a7Smrg 286181254a7Smrg r = strtoflt128 ("1.2345678", NULL); 287181254a7Smrg 288181254a7Smrg return 0; 289181254a7Smrg@} 290181254a7Smrg@end smallexample 291181254a7Smrg@end table 292181254a7Smrg 293181254a7Smrg 294181254a7Smrg@node quadmath_snprintf 295181254a7Smrg@section @code{quadmath_snprintf} --- Convert to string 296181254a7Smrg 297181254a7SmrgThe function @code{quadmath_snprintf} converts a @code{__float128} floating-point 298181254a7Smrgnumber into a string. It is a specialized alternative to @code{snprintf}, where 299181254a7Smrgthe format string is restricted to a single conversion specifier with @code{Q} 300181254a7Smrgmodifier and conversion specifier @code{e}, @code{E}, @code{f}, @code{F}, @code{g}, 301181254a7Smrg@code{G}, @code{a} or @code{A}, with no extra characters before or after the 302181254a7Smrgconversion specifier. The @code{%m$} or @code{*m$} style must not be used in 303181254a7Smrgthe format. 304181254a7Smrg 305181254a7Smrg@table @asis 306181254a7Smrg@item Syntax 307181254a7Smrg@code{int quadmath_snprintf (char *s, size_t size, const char *format, ...)} 308181254a7Smrg 309181254a7Smrg@item @emph{Arguments}: 310181254a7Smrg@multitable @columnfractions .15 .70 311181254a7Smrg@item @var{s} @tab output string 312*b1e83836Smrg@item @var{size} @tab byte size of the string, including trailing NUL 313181254a7Smrg@item @var{format} @tab conversion specifier string 314181254a7Smrg@end multitable 315181254a7Smrg 316181254a7Smrg@item Note 317181254a7SmrgOn some targets when supported by the C library hooks are installed 318181254a7Smrgfor @code{printf} family of functions, so that @code{printf ("%Qe", 1.2Q);} 319181254a7Smrgetc.@: works too. 320181254a7Smrg 321181254a7Smrg@item Example 322181254a7Smrg@smallexample 323181254a7Smrg#include <quadmath.h> 324181254a7Smrg#include <stdlib.h> 325181254a7Smrg#include <stdio.h> 326181254a7Smrg 327181254a7Smrgint main () 328181254a7Smrg@{ 329181254a7Smrg __float128 r; 330181254a7Smrg int prec = 20; 331181254a7Smrg int width = 46; 332181254a7Smrg char buf[128]; 333181254a7Smrg 334181254a7Smrg r = 2.0q; 335181254a7Smrg r = sqrtq (r); 336181254a7Smrg int n = quadmath_snprintf (buf, sizeof buf, "%+-#*.20Qe", width, r); 337181254a7Smrg if ((size_t) n < sizeof buf) 338181254a7Smrg printf ("%s\n", buf); 339181254a7Smrg /* Prints: +1.41421356237309504880e+00 */ 340181254a7Smrg quadmath_snprintf (buf, sizeof buf, "%Qa", r); 341181254a7Smrg if ((size_t) n < sizeof buf) 342181254a7Smrg printf ("%s\n", buf); 343181254a7Smrg /* Prints: 0x1.6a09e667f3bcc908b2fb1366ea96p+0 */ 344181254a7Smrg n = quadmath_snprintf (NULL, 0, "%+-#46.*Qe", prec, r); 345181254a7Smrg if (n > -1) 346181254a7Smrg @{ 347181254a7Smrg char *str = malloc (n + 1); 348181254a7Smrg if (str) 349181254a7Smrg @{ 350181254a7Smrg quadmath_snprintf (str, n + 1, "%+-#46.*Qe", prec, r); 351181254a7Smrg printf ("%s\n", str); 352181254a7Smrg /* Prints: +1.41421356237309504880e+00 */ 353181254a7Smrg @} 354181254a7Smrg free (str); 355181254a7Smrg @} 356181254a7Smrg return 0; 357181254a7Smrg@} 358181254a7Smrg@end smallexample 359181254a7Smrg 360181254a7Smrg@end table 361181254a7Smrg 362181254a7Smrg 363181254a7Smrg@c --------------------------------------------------------------------- 364181254a7Smrg@c GNU Free Documentation License 365181254a7Smrg@c --------------------------------------------------------------------- 366181254a7Smrg 367181254a7Smrg@include fdl.texi 368181254a7Smrg 369181254a7Smrg@c --------------------------------------------------------------------- 370181254a7Smrg@c Reporting Bugs 371181254a7Smrg@c --------------------------------------------------------------------- 372181254a7Smrg 373181254a7Smrg@c For BUGURL 374181254a7Smrg@include libquadmath-vers.texi 375181254a7Smrg 376181254a7Smrg@node Reporting Bugs 377181254a7Smrg@chapter Reporting Bugs 378181254a7Smrg 379181254a7SmrgBugs in the GCC Quad-Precision Math Library implementation should be 380181254a7Smrgreported via @value{BUGURL}. 381181254a7Smrg 382181254a7Smrg 383181254a7Smrg@c --------------------------------------------------------------------- 384181254a7Smrg@c Index 385181254a7Smrg@c --------------------------------------------------------------------- 386181254a7Smrg 387181254a7Smrg@c @node Index 388181254a7Smrg@c @unnumbered Index 389181254a7Smrg@c 390181254a7Smrg@c @printindex cp 391181254a7Smrg 392181254a7Smrg@bye 393