This manual documents the GCC Quad-Precision Math Library API.

Published by the Free Software Foundation 51 Franklin Street, Fifth Floor Boston, MA 02110-1301 USA

Copyright © 2010 Free Software Foundation, Inc.

     Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, with the Front-Cover Texts being ``A GNU Manual,'' and with the Back-Cover Texts as in (a) below.  A copy of the license is included in the section entitled ``GNU Free Documentation License.''

     (a) The FSF's Back-Cover Text is: ``You have the freedom to copy and modify this GNU manual.

Introduction
************

This manual documents the usage of libquadmath, the GCC Quad-Precision Math Library Application Programming Interface (API).

Typedef and constants
*********************

The following data type has been defined via typedef.

__complex128: __float128-based complex number

The following macros are defined, which give the numeric limits of the __float128 data type.

FLT128_MAX: largest finite number

FLT128_MIN: smallest positive number with full precision

FLT128_EPSILON: difference between 1 and the next larger
     representable number

FLT128_DENORM_MIN: smallest positive denormalized number

FLT128_MANT_DIG: number of digits in the mantissa (bit precision)

FLT128_MIN_EXP: maximal negative exponent

FLT128_MAX_EXP: maximal positive exponent

FLT128_DIG: number of decimal digits in the mantissa

FLT128_MIN_10_EXP: maximal negative decimal exponent

FLT128_MAX_10_EXP: maximal positive decimal exponent

The following mathematical constants of type __float128 are defined.

M_Eq: the constant e (Euler's number)

M_LOG2Eq: binary logarithm of 2

M_LOG10Eq: common, decimal logarithm of 2

M_LN2q: natural logarithm of 2

M_LN10q: natural logarithm of 10

M_PIq: pi

M_PI_2q: two pi

M_PI_4q: four pi

M_1_PIq: one over pi

M_2_PIq: one over two pi

M_2_SQRTPIq: two over square root of pi

M_SQRT2q: square root of 2

M_SQRT1_2q: one over square root of 2

Math Library Routines
*********************

The following mathematical functions are available:

acosq: arc cosine function

acoshq: inverse hyperbolic cosine function

asinq: arc sine function

asinhq: inverse hyperbolic sine function

atanq: arc tangent function

atanhq: inverse hyperbolic tangent function

atan2q: arc tangent function

cbrtq: cube root function

ceilq: ceiling value function

copysignq: copy sign of a number

coshq: hyperbolic cosine function

cosq: cosine function

erfq: error function

erfcq: complementary error function

expq: exponential function

expm1q: exponential minus 1 function

fabsq: absolute value function

fdimq: positive difference function

finiteq: check finiteness of value

floorq: floor value function

fmaq: fused multiply and add

fmaxq: determine maximum of two values

fminq: determine minimum of two values

fmodq: remainder value function

frexpq: extract mantissa and exponent

hypotq: Eucledian distance function

ilogbq: get exponent of the value

isinfq: check for infinity

isnanq: check for not a number

j0q: Bessel function of the first kind, first order

j1q: Bessel function of the first kind, second order

jnq: Bessel function of the first kind, N-th order

ldexpq: load exponent of the value

lgammaq: logarithmic gamma function

llrintq: round to nearest integer value

llroundq: round to nearest integer value away from zero

logq: natural logarithm function

log10q: base 10 logarithm function

log1pq: compute natural logarithm of the value plus one

log2q: base 2 logarithm function

lrintq: round to nearest integer value

lroundq: round to nearest integer value away from zero

modfq: decompose the floating-point number

nanq: return quiet NaN

nearbyintq: round to nearest integer

nextafterq: next representable floating-point number

powq: power function

remainderq: remainder function

remquoq: remainder and part of quotient

rintq: round-to-nearest integral value

roundq: round-to-nearest integral value, return __float128

scalblnq: compute exponent using FLT_RADIX

scalbnq: compute exponent using FLT_RADIX

signbitq: return sign bit

sincosq: calculate sine and cosine simulataneously

sinhq: hyperbolic sine function

sinq: sine function

sqrtq: square root function

tanq: tangent function

tanhq: hyperbolic tangent function

tgammaq: true gamma function

truncq: round to integer, towards zero

y0q: Bessel function of the second kind, first order

y1q: Bessel function of the second kind, second order

ynq: Bessel function of the second kind, N-th order

cabsq complex absolute value function

cargq: calculate the argument

cimagq imaginary part of complex number

crealq: real part of complex number

cacoshq: complex arc hyperbolic cosine function

cacosq: complex arc cosine function

casinhq: complex arc hyperbolic sine function

casinq: complex arc sine function

catanhq: complex arc hyperbolic tangent function

catanq: complex arc tangent function

ccosq complex cosine function:

ccoshq: complex hyperbolic cosine function

cexpq: complex exponential function

cexpiq: computes the exponential function of ``i'' times a
     real value

clogq: complex natural logarithm

clog10q: complex base 10 logarithm

conjq: complex conjugate function

cpowq: complex power function

cprojq: project into Riemann Sphere

csinq: complex sine function

csinhq: complex hyperbolic sine function

csqrtq: complex square root

ctanq: complex tangent function

ctanhq: complex hyperbolic tangent function

I/O Library Routines
********************

strtoflt128 --- Convert from string
===================================

The function strtoflt128 converts a string into a __float128 number.

Syntax
     __float128 strtoflt128 (const char *s, char **sp)

Arguments:

     S    input string
     SP   the address of the next character in the string

     The argument SP contains, if not NULL, the address of the next character following the parts of the string, which have been read.

Example

          #include <quadmath.h>

          int main ()
          {
            __float128 r;

            r = strtoflt128 ("1.2345678", NULL);

            return 0;
          }

quadmath_snprintf --- Convert to string
=======================================

The function quadmath_snprintf converts a __float128 floating-point number into a string.  It is a specialized alternative to snprintf, where the format string is restricted to a single conversion specifier with Q modifier and conversion specifier e, E, f, F, g, G, a or A, with no extra characters before or after the conversion specifier.  The %m$ or *m$ style must not be used in the format.

Syntax
     int quadmath_snprintf (char *s, size_t size, const char *format, ...)

Arguments:

     S      output string
     SIZE   byte size of the string, including tailing NUL
     FORMAT   conversion specifier string

Note
     On some targets when supported by the C library hooks are installed for printf family of functions, so that printf ("%Qe", 1.2Q); etc. works too.

Example

          #include <quadmath.h>
          #include <stdlib.h>
          #include <stdio.h>

          int main ()
          {
            __float128 r;
            int prec = 20;
            int width = 46;
            char buf[128];

            r = 2.0q;
            r = sqrtq (r);
            int n = quadmath_snprintf (buf, sizeof buf, "%+-#*.20Qe", width, r);
            if ((size_t) n < sizeof buf)
              printf ("%s\n", buf);
              /* Prints: +1.41421356237309504880e+00 */
            quadmath_snprintf (buf, sizeof buf, "%Qa", r);
            if ((size_t) n < sizeof buf)
              printf ("%s\n", buf);
              /* Prints: 0x1.6a09e667f3bcc908b2fb1366ea96p+0 */
            n = quadmath_snprintf (NULL, 0, "%+-#46.*Qe", prec, r);
            if (n > -1)
              {
                char *str = malloc (n + 1);
                if (str)
                  {
                    quadmath_snprintf (str, n + 1, "%+-#46.*Qe", prec, r);
                    printf ("%s\n", str);
                    /* Prints: +1.41421356237309504880e+00 */
                  }
                free (str);
              }
            return 0;
          }

     [file fdl.texi not included]

     [file libquadmath-vers.texi not included]

Reporting Bugs
**************

Bugs in the GCC Quad-Precision Math Library implementation should be reported via BUGURL.