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