Update.
[platform/upstream/glibc.git] / manual / arith.texi
index bb7ec34..a422677 100644 (file)
@@ -152,7 +152,11 @@ not have to worry about the type of their argument.
 @comment math.h
 @comment BSD
 @deftypefun int isinf (double @var{x})
+@comment math.h
+@comment BSD
 @deftypefunx int isinff (float @var{x})
+@comment math.h
+@comment BSD
 @deftypefunx int isinfl (long double @var{x})
 This function returns @code{-1} if @var{x} represents negative infinity,
 @code{1} if @var{x} represents positive infinity, and @code{0} otherwise.
@@ -161,7 +165,11 @@ This function returns @code{-1} if @var{x} represents negative infinity,
 @comment math.h
 @comment BSD
 @deftypefun int isnan (double @var{x})
+@comment math.h
+@comment BSD
 @deftypefunx int isnanf (float @var{x})
+@comment math.h
+@comment BSD
 @deftypefunx int isnanl (long double @var{x})
 This function returns a nonzero value if @var{x} is a ``not a number''
 value, and zero otherwise.
@@ -179,7 +187,11 @@ function for some reason, you can write
 @comment math.h
 @comment BSD
 @deftypefun int finite (double @var{x})
+@comment math.h
+@comment BSD
 @deftypefunx int finitef (float @var{x})
+@comment math.h
+@comment BSD
 @deftypefunx int finitel (long double @var{x})
 This function returns a nonzero value if @var{x} is finite or a ``not a
 number'' value, and zero otherwise.
@@ -239,7 +251,7 @@ exceptions happened.
 Alternatively, you can enable @dfn{traps} for exceptions.  In that case,
 when an exception is raised, your program will receive the @code{SIGFPE}
 signal.  The default action for this signal is to terminate the
-program.  @xref{Signal Handling} for how you can change the effect of
+program.  @xref{Signal Handling}, for how you can change the effect of
 the signal.
 
 @findex matherr
@@ -566,7 +578,11 @@ to test for overflow on both old and new hardware.
 @comment math.h
 @comment ISO
 @deftypevr Macro double HUGE_VAL
+@comment math.h
+@comment ISO
 @deftypevrx Macro float HUGE_VALF
+@comment math.h
+@comment ISO
 @deftypevrx Macro {long double} HUGE_VALL
 An expression representing a particular very large number.  On machines
 that use @w{IEEE 754} floating point format, @code{HUGE_VAL} is infinity.
@@ -810,27 +826,39 @@ whose imaginary part is @var{y}, the absolute value is @w{@code{sqrt
 @pindex math.h
 @pindex stdlib.h
 Prototypes for @code{abs}, @code{labs} and @code{llabs} are in @file{stdlib.h};
+@code{imaxabs} is declared in @file{inttypes.h};
 @code{fabs}, @code{fabsf} and @code{fabsl} are declared in @file{math.h}.
 @code{cabs}, @code{cabsf} and @code{cabsl} are declared in @file{complex.h}.
 
 @comment stdlib.h
 @comment ISO
 @deftypefun int abs (int @var{number})
+@comment stdlib.h
+@comment ISO
 @deftypefunx {long int} labs (long int @var{number})
+@comment stdlib.h
+@comment ISO
 @deftypefunx {long long int} llabs (long long int @var{number})
+@comment inttypes.h
+@comment ISO
+@deftypefunx intmax_t imaxabs (intmax_t @var{number})
 These functions return the absolute value of @var{number}.
 
 Most computers use a two's complement integer representation, in which
 the absolute value of @code{INT_MIN} (the smallest possible @code{int})
 cannot be represented; thus, @w{@code{abs (INT_MIN)}} is not defined.
 
-@code{llabs} is new to @w{ISO C 9x}
+@code{llabs} and @code{imaxdiv} are new to @w{ISO C 9x}.
 @end deftypefun
 
 @comment math.h
 @comment ISO
 @deftypefun double fabs (double @var{number})
+@comment math.h
+@comment ISO
 @deftypefunx float fabsf (float @var{number})
+@comment math.h
+@comment ISO
 @deftypefunx {long double} fabsl (long double @var{number})
 This function returns the absolute value of the floating-point number
 @var{number}.
@@ -839,7 +867,11 @@ This function returns the absolute value of the floating-point number
 @comment complex.h
 @comment ISO
 @deftypefun double cabs (complex double @var{z})
+@comment complex.h
+@comment ISO
 @deftypefunx float cabsf (complex float @var{z})
+@comment complex.h
+@comment ISO
 @deftypefunx {long double} cabsl (complex long double @var{z})
 These functions return the absolute  value of the complex number @var{z}
 (@pxref{Complex Numbers}).  The absolute value of a complex number is:
@@ -851,7 +883,7 @@ sqrt (creal (@var{z}) * creal (@var{z}) + cimag (@var{z}) * cimag (@var{z}))
 This function should always be used instead of the direct formula
 because it takes special care to avoid losing precision.  It may also
 take advantage of hardware support for this operation. See @code{hypot}
-in @xref{Exponents and Logarithms}.
+in @ref{Exponents and Logarithms}.
 @end deftypefun
 
 @node Normalization Functions
@@ -872,7 +904,11 @@ All these functions are declared in @file{math.h}.
 @comment math.h
 @comment ISO
 @deftypefun double frexp (double @var{value}, int *@var{exponent})
+@comment math.h
+@comment ISO
 @deftypefunx float frexpf (float @var{value}, int *@var{exponent})
+@comment math.h
+@comment ISO
 @deftypefunx {long double} frexpl (long double @var{value}, int *@var{exponent})
 These functions are used to split the number @var{value}
 into a normalized fraction and an exponent.
@@ -893,7 +929,11 @@ zero is stored in @code{*@var{exponent}}.
 @comment math.h
 @comment ISO
 @deftypefun double ldexp (double @var{value}, int @var{exponent})
+@comment math.h
+@comment ISO
 @deftypefunx float ldexpf (float @var{value}, int @var{exponent})
+@comment math.h
+@comment ISO
 @deftypefunx {long double} ldexpl (long double @var{value}, int @var{exponent})
 These functions return the result of multiplying the floating-point
 number @var{value} by 2 raised to the power @var{exponent}.  (It can
@@ -909,7 +949,11 @@ equivalent to those of @code{ldexp} and @code{frexp}.
 @comment math.h
 @comment BSD
 @deftypefun double logb (double @var{x})
+@comment math.h
+@comment BSD
 @deftypefunx float logbf (float @var{x})
+@comment math.h
+@comment BSD
 @deftypefunx {long double} logbl (long double @var{x})
 These functions return the integer part of the base-2 logarithm of
 @var{x}, an integer value represented in type @code{double}.  This is
@@ -931,7 +975,11 @@ the value that @code{frexp} would store into @code{*@var{exponent}}.
 @comment math.h
 @comment BSD
 @deftypefun double scalb (double @var{value}, int @var{exponent})
+@comment math.h
+@comment BSD
 @deftypefunx float scalbf (float @var{value}, int @var{exponent})
+@comment math.h
+@comment BSD
 @deftypefunx {long double} scalbl (long double @var{value}, int @var{exponent})
 The @code{scalb} function is the BSD name for @code{ldexp}.
 @end deftypefun
@@ -939,7 +987,11 @@ The @code{scalb} function is the BSD name for @code{ldexp}.
 @comment math.h
 @comment BSD
 @deftypefun {long long int} scalbn (double @var{x}, int n)
+@comment math.h
+@comment BSD
 @deftypefunx {long long int} scalbnf (float @var{x}, int n)
+@comment math.h
+@comment BSD
 @deftypefunx {long long int} scalbnl (long double @var{x}, int n)
 @code{scalbn} is identical to @code{scalb}, except that the exponent
 @var{n} is an @code{int} instead of a floating-point number.
@@ -948,7 +1000,11 @@ The @code{scalb} function is the BSD name for @code{ldexp}.
 @comment math.h
 @comment BSD
 @deftypefun {long long int} scalbln (double @var{x}, long int n)
+@comment math.h
+@comment BSD
 @deftypefunx {long long int} scalblnf (float @var{x}, long int n)
+@comment math.h
+@comment BSD
 @deftypefunx {long long int} scalblnl (long double @var{x}, long int n)
 @code{scalbln} is identical to @code{scalb}, except that the exponent
 @var{n} is a @code{long int} instead of a floating-point number.
@@ -957,7 +1013,11 @@ The @code{scalb} function is the BSD name for @code{ldexp}.
 @comment math.h
 @comment BSD
 @deftypefun {long long int} significand (double @var{x})
+@comment math.h
+@comment BSD
 @deftypefunx {long long int} significandf (float @var{x})
+@comment math.h
+@comment BSD
 @deftypefunx {long long int} significandl (long double @var{x})
 @code{significand} returns the mantissa of @var{x} scaled to the range
 @math{[1, 2)}.
@@ -987,7 +1047,11 @@ result as a @code{double} instead to get around this problem.
 @comment math.h
 @comment ISO
 @deftypefun double ceil (double @var{x})
+@comment math.h
+@comment ISO
 @deftypefunx float ceilf (float @var{x})
+@comment math.h
+@comment ISO
 @deftypefunx {long double} ceill (long double @var{x})
 These functions round @var{x} upwards to the nearest integer,
 returning that value as a @code{double}.  Thus, @code{ceil (1.5)}
@@ -997,7 +1061,11 @@ is @code{2.0}.
 @comment math.h
 @comment ISO
 @deftypefun double floor (double @var{x})
+@comment math.h
+@comment ISO
 @deftypefunx float floorf (float @var{x})
+@comment math.h
+@comment ISO
 @deftypefunx {long double} floorl (long double @var{x})
 These functions round @var{x} downwards to the nearest
 integer, returning that value as a @code{double}.  Thus, @code{floor
@@ -1007,7 +1075,11 @@ integer, returning that value as a @code{double}.  Thus, @code{floor
 @comment math.h
 @comment ISO
 @deftypefun double trunc (double @var{x})
+@comment math.h
+@comment ISO
 @deftypefunx float truncf (float @var{x})
+@comment math.h
+@comment ISO
 @deftypefunx {long double} truncl (long double @var{x})
 @code{trunc} is another name for @code{floor}
 @end deftypefun
@@ -1015,7 +1087,11 @@ integer, returning that value as a @code{double}.  Thus, @code{floor
 @comment math.h
 @comment ISO
 @deftypefun double rint (double @var{x})
+@comment math.h
+@comment ISO
 @deftypefunx float rintf (float @var{x})
+@comment math.h
+@comment ISO
 @deftypefunx {long double} rintl (long double @var{x})
 These functions round @var{x} to an integer value according to the
 current rounding mode.  @xref{Floating Point Parameters}, for
@@ -1031,7 +1107,11 @@ inexact exception.
 @comment math.h
 @comment ISO
 @deftypefun double nearbyint (double @var{x})
+@comment math.h
+@comment ISO
 @deftypefunx float nearbyintf (float @var{x})
+@comment math.h
+@comment ISO
 @deftypefunx {long double} nearbyintl (long double @var{x})
 These functions return the same value as the @code{rint} functions, but
 do not raise the inexact exception if @var{x} is not an integer.
@@ -1040,7 +1120,11 @@ do not raise the inexact exception if @var{x} is not an integer.
 @comment math.h
 @comment ISO
 @deftypefun double round (double @var{x})
+@comment math.h
+@comment ISO
 @deftypefunx float roundf (float @var{x})
+@comment math.h
+@comment ISO
 @deftypefunx {long double} roundl (long double @var{x})
 These functions are similar to @code{rint}, but they round halfway
 cases away from zero instead of to the nearest even integer.
@@ -1049,7 +1133,11 @@ cases away from zero instead of to the nearest even integer.
 @comment math.h
 @comment ISO
 @deftypefun {long int} lrint (double @var{x})
+@comment math.h
+@comment ISO
 @deftypefunx {long int} lrintf (float @var{x})
+@comment math.h
+@comment ISO
 @deftypefunx {long int} lrintl (long double @var{x})
 These functions are just like @code{rint}, but they return a
 @code{long int} instead of a floating-point number.
@@ -1058,7 +1146,11 @@ These functions are just like @code{rint}, but they return a
 @comment math.h
 @comment ISO
 @deftypefun {long long int} llrint (double @var{x})
+@comment math.h
+@comment ISO
 @deftypefunx {long long int} llrintf (float @var{x})
+@comment math.h
+@comment ISO
 @deftypefunx {long long int} llrintl (long double @var{x})
 These functions are just like @code{rint}, but they return a
 @code{long long int} instead of a floating-point number.
@@ -1067,7 +1159,11 @@ These functions are just like @code{rint}, but they return a
 @comment math.h
 @comment ISO
 @deftypefun {long int} lround (double @var{x})
+@comment math.h
+@comment ISO
 @deftypefunx {long int} lroundf (float @var{x})
+@comment math.h
+@comment ISO
 @deftypefunx {long int} lroundl (long double @var{x})
 These functions are just like @code{round}, but they return a
 @code{long int} instead of a floating-point number.
@@ -1076,7 +1172,11 @@ These functions are just like @code{round}, but they return a
 @comment math.h
 @comment ISO
 @deftypefun {long long int} llround (double @var{x})
+@comment math.h
+@comment ISO
 @deftypefunx {long long int} llroundf (float @var{x})
+@comment math.h
+@comment ISO
 @deftypefunx {long long int} llroundl (long double @var{x})
 These functions are just like @code{round}, but they return a
 @code{long long int} instead of a floating-point number.
@@ -1086,7 +1186,11 @@ These functions are just like @code{round}, but they return a
 @comment math.h
 @comment ISO
 @deftypefun double modf (double @var{value}, double *@var{integer-part})
+@comment math.h
+@comment ISO
 @deftypefunx float modff (float @var{value}, float *@var{integer-part})
+@comment math.h
+@comment ISO
 @deftypefunx {long double} modfl (long double @var{value}, long double *@var{integer-part})
 These functions break the argument @var{value} into an integer part and a
 fractional part (between @code{-1} and @code{1}, exclusive).  Their sum
@@ -1108,7 +1212,11 @@ suits your problem.
 @comment math.h
 @comment ISO
 @deftypefun double fmod (double @var{numerator}, double @var{denominator})
+@comment math.h
+@comment ISO
 @deftypefunx float fmodf (float @var{numerator}, float @var{denominator})
+@comment math.h
+@comment ISO
 @deftypefunx {long double} fmodl (long double @var{numerator}, long double @var{denominator})
 These functions compute the remainder from the division of
 @var{numerator} by @var{denominator}.  Specifically, the return value is
@@ -1126,7 +1234,11 @@ If @var{denominator} is zero, @code{fmod} signals a domain error.
 @comment math.h
 @comment BSD
 @deftypefun double drem (double @var{numerator}, double @var{denominator})
+@comment math.h
+@comment BSD
 @deftypefunx float dremf (float @var{numerator}, float @var{denominator})
+@comment math.h
+@comment BSD
 @deftypefunx {long double} dreml (long double @var{numerator}, long double @var{denominator})
 These functions are like @code{fmod} except that they rounds the
 internal quotient @var{n} to the nearest integer instead of towards zero
@@ -1145,7 +1257,11 @@ If @var{denominator} is zero, @code{drem} signals a domain error.
 @comment math.h
 @comment BSD
 @deftypefun double remainder (double @var{numerator}, double @var{denominator})
+@comment math.h
+@comment BSD
 @deftypefunx float remainderf (float @var{numerator}, float @var{denominator})
+@comment math.h
+@comment BSD
 @deftypefunx {long double} remainderl (long double @var{numerator}, long double @var{denominator})
 This function is another name for @code{drem}.
 @end deftypefun
@@ -1162,7 +1278,11 @@ bits.
 @comment math.h
 @comment ISO
 @deftypefun double copysign (double @var{x}, double @var{y})
+@comment math.h
+@comment ISO
 @deftypefunx float copysignf (float @var{x}, float @var{y})
+@comment math.h
+@comment ISO
 @deftypefunx {long double} copysignl (long double @var{x}, long double @var{y})
 These functions return @var{x} but with the sign of @var{y}.  They work
 even if @var{x} or @var{y} are NaN or zero.  Both of these can carry a
@@ -1191,7 +1311,11 @@ false, but @code{signbit (-0.0)} will return a nonzero value.
 @comment math.h
 @comment ISO
 @deftypefun double nextafter (double @var{x}, double @var{y})
+@comment math.h
+@comment ISO
 @deftypefunx float nextafterf (float @var{x}, float @var{y})
+@comment math.h
+@comment ISO
 @deftypefunx {long double} nextafterl (long double @var{x}, long double @var{y})
 The @code{nextafter} function returns the next representable neighbor of
 @var{x} in the direction towards @var{y}.  The size of the step between
@@ -1209,9 +1333,13 @@ recommended functions in @w{IEEE 754}/@w{IEEE 854}).
 
 @comment math.h
 @comment ISO
-@deftypefun {long long int} nextafterx (double @var{x}, long double @var{y})
-@deftypefunx {long long int} nextafterxf (float @var{x}, long double @var{y})
-@deftypefunx {long long int} nextafterxl (long double @var{x}, long double @var{y})
+@deftypefun double nexttoward (double @var{x}, long double @var{y})
+@comment math.h
+@comment ISO
+@deftypefunx float nexttowardf (float @var{x}, long double @var{y})
+@comment math.h
+@comment ISO
+@deftypefunx {long double} nexttowardl (long double @var{x}, long double @var{y})
 These functions are identical to the corresponding versions of
 @code{nextafter} except that their second argument is a @code{long
 double}.
@@ -1221,7 +1349,11 @@ double}.
 @comment math.h
 @comment ISO
 @deftypefun double nan (const char *@var{tagp})
+@comment math.h
+@comment ISO
 @deftypefunx float nanf (const char *@var{tagp})
+@comment math.h
+@comment ISO
 @deftypefunx {long double} nanl (const char *@var{tagp})
 The @code{nan} function returns a representation of NaN, provided that
 NaN is supported by the target platform.
@@ -1328,7 +1460,11 @@ perform these operations faster than the equivalent C code.
 @comment math.h
 @comment ISO
 @deftypefun double fmin (double @var{x}, double @var{y})
+@comment math.h
+@comment ISO
 @deftypefunx float fminf (float @var{x}, float @var{y})
+@comment math.h
+@comment ISO
 @deftypefunx {long double} fminl (long double @var{x}, long double @var{y})
 The @code{fmin} function returns the lesser of the two values @var{x}
 and @var{y}.  It is similar to the expression
@@ -1344,7 +1480,11 @@ are NaN, NaN is returned.
 @comment math.h
 @comment ISO
 @deftypefun double fmax (double @var{x}, double @var{y})
+@comment math.h
+@comment ISO
 @deftypefunx float fmaxf (float @var{x}, float @var{y})
+@comment math.h
+@comment ISO
 @deftypefunx {long double} fmaxl (long double @var{x}, long double @var{y})
 The @code{fmax} function returns the greater of the two values @var{x}
 and @var{y}.
@@ -1356,7 +1496,11 @@ are NaN, NaN is returned.
 @comment math.h
 @comment ISO
 @deftypefun double fdim (double @var{x}, double @var{y})
+@comment math.h
+@comment ISO
 @deftypefunx float fdimf (float @var{x}, float @var{y})
+@comment math.h
+@comment ISO
 @deftypefunx {long double} fdiml (long double @var{x}, long double @var{y})
 The @code{fdim} function returns the positive difference between
 @var{x} and @var{y}.  The positive difference is @math{@var{x} -
@@ -1368,7 +1512,11 @@ If @var{x}, @var{y}, or both are NaN, NaN is returned.
 @comment math.h
 @comment ISO
 @deftypefun double fma (double @var{x}, double @var{y}, double @var{z})
+@comment math.h
+@comment ISO
 @deftypefunx float fmaf (float @var{x}, float @var{y}, float @var{z})
+@comment math.h
+@comment ISO
 @deftypefunx {long double} fmal (long double @var{x}, long double @var{y}, long double @var{z})
 @cindex butterfly
 The @code{fma} function performs floating-point multiply-add.  This is
@@ -1494,7 +1642,11 @@ available in three variants, one for each of the three complex types.
 @comment complex.h
 @comment ISO
 @deftypefun double creal (complex double @var{z})
+@comment complex.h
+@comment ISO
 @deftypefunx float crealf (complex float @var{z})
+@comment complex.h
+@comment ISO
 @deftypefunx {long double} creall (complex long double @var{z})
 These functions return the real part of the complex number @var{z}.
 @end deftypefun
@@ -1502,7 +1654,11 @@ These functions return the real part of the complex number @var{z}.
 @comment complex.h
 @comment ISO
 @deftypefun double cimag (complex double @var{z})
+@comment complex.h
+@comment ISO
 @deftypefunx float cimagf (complex float @var{z})
+@comment complex.h
+@comment ISO
 @deftypefunx {long double} cimagl (complex long double @var{z})
 These functions return the imaginary part of the complex number @var{z}.
 @end deftypefun
@@ -1510,7 +1666,11 @@ These functions return the imaginary part of the complex number @var{z}.
 @comment complex.h
 @comment ISO
 @deftypefun {complex double} conj (complex double @var{z})
+@comment complex.h
+@comment ISO
 @deftypefunx {complex float} conjf (complex float @var{z})
+@comment complex.h
+@comment ISO
 @deftypefunx {complex long double} conjl (complex long double @var{z})
 These functions return the conjugate value of the complex number
 @var{z}.  The conjugate of a complex number has the same real part and a
@@ -1520,7 +1680,11 @@ negated imaginary part.  In other words, @samp{conj(a + bi) = a + -bi}.
 @comment complex.h
 @comment ISO
 @deftypefun double carg (complex double @var{z})
+@comment complex.h
+@comment ISO
 @deftypefunx float cargf (complex float @var{z})
+@comment complex.h
+@comment ISO
 @deftypefunx {long double} cargl (complex long double @var{z})
 These functions return the argument of the complex number @var{z}.
 The argument of a complex number is the angle in the complex plane
@@ -1534,7 +1698,11 @@ to @math{2@pi{}}.
 @comment complex.h
 @comment ISO
 @deftypefun {complex double} cproj (complex double @var{z})
+@comment complex.h
+@comment ISO
 @deftypefunx {complex float} cprojf (complex float @var{z})
+@comment complex.h
+@comment ISO
 @deftypefunx {complex long double} cprojl (complex long double @var{z})
 These functions return the projection of the complex value @var{z} onto
 the Riemann sphere.  Values with a infinite imaginary part are projected
@@ -1656,6 +1824,34 @@ a structure of type @code{lldiv_t}.
 The @code{lldiv} function was added in @w{ISO C 9x}.
 @end deftypefun
 
+@comment inttypes.h
+@comment ISO
+@deftp {Data Type} imaxdiv_t
+This is a structure type used to hold the result returned by the @code{imaxdiv}
+function.  It has the following members:
+
+@table @code
+@item intmax_t quot
+The quotient from the division.
+
+@item intmax_t rem
+The remainder from the division.
+@end table
+
+(This is identical to @code{div_t} except that the components are of
+type @code{intmax_t} rather than @code{int}.)
+@end deftp
+
+@comment inttypes.h
+@comment ISO
+@deftypefun imaxdiv_t imaxdiv (intmax_t @var{numerator}, intmax_t @var{denominator})
+The @code{imaxdiv} function is like the @code{div} function, but the
+arguments are of type @code{intmax_t} and the result is returned as
+a structure of type @code{imaxdiv_t}.
+
+The @code{imaxdiv} function was added in @w{ISO C 9x}.
+@end deftypefun
+
 
 @node Parsing of Numbers
 @section Parsing of Numbers
@@ -1908,7 +2104,7 @@ An optional plus or minus sign (@samp{+} or @samp{-}).
 @item
 A nonempty sequence of digits optionally containing a decimal-point
 character---normally @samp{.}, but it depends on the locale
-(@pxref{Numeric Formatting}).
+(@pxref{General Numeric}).
 
 @item
 An optional exponent part, consisting of a character @samp{e} or
@@ -1952,6 +2148,8 @@ examining @var{errno} and @var{tailptr}.
 @comment stdlib.h
 @comment GNU
 @deftypefun float strtof (const char *@var{string}, char **@var{tailptr})
+@comment stdlib.h
+@comment GNU
 @deftypefunx {long double} strtold (const char *@var{string}, char **@var{tailptr})
 These functions are analogous to @code{strtod}, but return @code{float}
 and @code{long double} values respectively.  They report errors in the