Lines Matching refs:code

43 have three variants, one each for @code{double}, @code{float}, and
44 @code{long double} arguments. The @code{double} versions are mostly
45 defined in @w{ISO C89}. The @code{float} and @code{long double}
49 situation. For most calculations, the @code{float} functions are the
50 fastest. On the other hand, the @code{long double} functions have the
51 highest precision. @code{double} is somewhere in between. It is
53 Not all machines have a distinct @code{long double} type; it may be the
54 same as @code{double}.
56 @Theglibc{} also provides @code{_Float@var{N}} and
57 @code{_Float@var{N}x} types. These types are defined in @w{ISO/IEC TS
59 are not machine-dependent. When such a type, such as @code{_Float128},
61 functions provided for @code{double}, @code{float}, and @code{long
63 manual, the @code{_Float@var{N}} and @code{_Float@var{N}x} variants of
64 these functions are described along with the @code{double},
65 @code{float}, and @code{long double} variants and they come from
68 Support for @code{_Float@var{N}} or @code{_Float@var{N}x} types is
69 provided for @code{_Float32}, @code{_Float64} and @code{_Float32x} on
71 It is also provided for @code{_Float128} and @code{_Float64x} on
86 * FP Function Optimizations:: Fast code or small code.
95 All values are defined as preprocessor macros starting with @code{M_}.
98 @vtable @code
102 The logarithm to base @code{2} of @code{M_E}.
104 The logarithm to base @code{10} of @code{M_E}.
106 The natural logarithm of @code{2}.
108 The natural logarithm of @code{10}.
129 @code{_XOPEN_SOURCE=500}, or a more general feature select macro, is
133 All values are of type @code{double}. As an extension, @theglibc{}
134 also defines these constants with type @code{long double} and
135 @code{float}. The @code{long double} macros have a lowercase @samp{l}
136 while the @code{float} macros have a lowercase @samp{f} appended to
137 their names: @code{M_El}, @code{M_PIl}, and so forth. These are only
138 available if @code{_GNU_SOURCE} is defined.
141 @code{_Float@var{N}} and @code{_Float@var{N}x} for the machines that
143 @code{_GNU_SOURCE} is defined. When available, the macros names are
145 for the type @code{_Float128}.
148 @emph{Note:} Some programs use a constant named @code{PI} which has the
149 same value as @code{M_PI}. This constant is not standard; it may have
153 replace @code{PI} with @code{M_PI} throughout, or put @samp{-DPI=M_PI}
160 These are the familiar @code{sin}, @code{cos}, and @code{tan} functions.
165 The math library normally defines @code{M_PI} to a @code{double}
175 You can also compute the value of pi with the expression @code{acos
188 radians. The return value is in the range @code{-1} to @code{1}.
201 radians. The return value is in the range @code{-1} to @code{1}.
218 singularities, @code{tan} will signal overflow.
221 In many applications where @code{sin} and @code{cos} are used, the sine
233 These functions return the sine of @var{x} in @code{*@var{sinx}} and the
234 cosine of @var{x} in @code{*@var{cosx}}, where @var{x} is given in
235 radians. Both values, @code{*@var{sinx}} and @code{*@var{cosx}}, are in
236 the range of @code{-1} to @code{1}.
238 All these functions, including the @code{_Float@var{N}} and
239 @code{_Float@var{N}x} variants, are GNU extensions. Portable programs
316 integer. @code{ctan} may signal overflow if @var{z} is too close to a
341 one between @code{-pi/2} and @code{pi/2} (inclusive).
344 over the domain @code{-1} to @code{1}. If @var{x} is outside the
345 domain, @code{asin} signals a domain error.
360 returned is the one between @code{0} and @code{pi} (inclusive).
363 over the domain @code{-1} to @code{1}. If @var{x} is outside the
364 domain, @code{acos} signals a domain error.
379 returned is the one between @code{-pi/2} and @code{pi/2} (inclusive).
394 and is in the range @code{-pi} to @code{pi}, inclusive.
397 @code{atan2} returns the signed angle between the line from the origin
398 to that point and the x-axis. Thus, @code{atan2} is useful for
400 radial coordinate, use @code{hypot}; see @ref{Exponents and
404 If both @var{x} and @var{y} are zero, @code{atan2} returns zero.
422 Unlike the real-valued functions, @code{casin} is defined for all
438 Unlike the real-valued functions, @code{cacos} is defined for all
472 These functions compute @code{e} (the base of natural logarithms) raised
476 @code{exp} signals overflow.
488 These functions compute @code{2} raised to the power @var{x}.
489 Mathematically, @code{exp2 (x)} is the same as @code{exp (x * log (2))}.
501 These functions compute @code{10} raised to the power @var{x}.
502 Mathematically, @code{exp10 (x)} is the same as @code{exp (x * log (10))}.
504 The @code{exp10} functions are from TS 18661-4:2015.
517 These functions compute the natural logarithm of @var{x}. @code{exp (log
521 If @var{x} is negative, @code{log} signals a domain error. If @var{x}
536 @code{log10 (@var{x})} equals @code{log (@var{x}) / log (10)}.
550 @code{log2 (@var{x})} equals @code{log (@var{x}) / log (2)}.
563 floating-point value. If @code{FLT_RADIX} is two, @code{logb} is equal
564 to @code{floor (log2 (x))}, except it's probably faster.
566 If @var{x} is de-normalized, @code{logb} returns the exponent @var{x}
568 negative), @code{logb} returns @math{@infinity{}}. If @var{x} is zero,
569 @code{logb} returns @math{@infinity{}}. It does not signal.
588 These functions are equivalent to the corresponding @code{logb}
590 @code{ilogb}, @code{ilogbf}, and @code{ilogbl} functions are from ISO
591 C99; the @code{llogb}, @code{llogbf}, @code{llogbl} functions are from
592 TS 18661-1:2014; the @code{ilogbfN}, @code{ilogbfNx}, @code{llogbfN},
593 and @code{llogbfNx} functions are from TS 18661-3:2015.
597 Since integers cannot represent infinity and NaN, @code{ilogb} instead
603 @code{ilogb} returns this value if its argument is @code{0}. The
604 numeric value is either @code{INT_MIN} or @code{-INT_MAX}.
611 @code{llogb} returns this value if its argument is @code{0}. The
612 numeric value is either @code{LONG_MIN} or @code{-LONG_MAX}.
619 @code{ilogb} returns this value if its argument is @code{NaN}. The
620 numeric value is either @code{INT_MIN} or @code{INT_MAX}.
627 @code{llogb} returns this value if its argument is @code{NaN}. The
628 numeric value is either @code{LONG_MIN} or @code{LONG_MAX}.
634 proper way to test the result of @code{ilogb} is as follows:
668 Mathematically, @code{pow} would return a complex number when @var{base}
669 is negative and @var{power} is not an integral value. @code{pow} can't
670 do that, so instead it signals a domain error. @code{pow} may also
686 If @var{x} is negative, @code{sqrt} signals a domain error.
713 These functions return @code{sqrt (@var{x}*@var{x} +
718 much smaller. See also the function @code{cabs} in @ref{Absolute Value}.
730 These functions return a value equivalent to @code{exp (@var{x}) - 1}.
732 near zero---a case where @code{exp (@var{x}) - 1} would be inaccurate owing
745 These functions return a value equivalent to @w{@code{log (1 + @var{x})}}.
765 These functions return @code{e} (the base of natural
797 @code{clog} has a pole at 0, and will signal overflow if @var{z} equals
820 All these functions, including the @code{_Float@var{N}} and
821 @code{_Float@var{N}x} variants, are GNU extensions.
847 @var{power}. This is equivalent to @w{@code{cexp (y * clog (x))}}
867 mathematically as @w{@code{(exp (@var{x}) - exp (-@var{x})) / 2}}. They
881 defined mathematically as @w{@code{(exp (@var{x}) + exp (-@var{x})) / 2}}.
895 defined mathematically as @w{@code{sinh (@var{x}) / cosh (@var{x})}}.
914 mathematically as @w{@code{(exp (@var{z}) - exp (-@var{z})) / 2}}.
927 mathematically as @w{@code{(exp (@var{z}) + exp (-@var{z})) / 2}}.
940 defined mathematically as @w{@code{csinh (@var{z}) / ccosh (@var{z})}}.
970 @code{1}, @code{acosh} signals a domain error.
984 @var{x} is greater than @code{1}, @code{atanh} signals a domain error;
985 if it is equal to 1, @code{atanh} returns infinity.
1050 @code{erf} returns the error function of @var{x}. The error
1071 @code{erfc} returns @code{1.0 - erf(@var{x})}, but computed in a
1084 @code{lgamma} returns the natural logarithm of the absolute value of
1097 @var{signgam}, which is declared in @file{math.h}. It is @code{1} if
1098 the intermediate result was positive or zero, or @code{-1} if it was
1101 To compute the real gamma function you can use the @code{tgamma}
1109 @code{lgamma} will raise the zero divide exception if evaluated at a
1122 @code{lgamma_r} is just like @code{lgamma}, but it stores the sign of
1126 The @code{lgammaf@var{N}_r} and @code{lgammaf@var{N}x_r} functions are
1136 @code{lgamma} etc. It is better to use @code{lgamma} since for one the
1137 name reflects better the actual computation, and moreover @code{lgamma} is
1138 standardized in @w{ISO C99} while @code{gamma} is not.
1155 @code{tgamma} applies the gamma function to @var{x}. The gamma
1166 This function was introduced in @w{ISO C99}. The @code{_Float@var{N}}
1167 and @code{_Float@var{N}x} variants were introduced in @w{ISO/IEC TS
1180 @code{j0} returns the Bessel function of the first kind of order 0 of
1183 The @code{_Float@var{N}} and @code{_Float@var{N}x} variants are GNU
1196 @code{j1} returns the Bessel function of the first kind of order 1 of
1199 The @code{_Float@var{N}} and @code{_Float@var{N}x} variants are GNU
1212 @code{jn} returns the Bessel function of the first kind of order
1215 The @code{_Float@var{N}} and @code{_Float@var{N}x} variants are GNU
1228 @code{y0} returns the Bessel function of the second kind of order 0 of
1230 is negative, @code{y0} signals a domain error; if it is zero,
1231 @code{y0} signals overflow and returns @math{-@infinity}.
1233 The @code{_Float@var{N}} and @code{_Float@var{N}x} variants are GNU
1246 @code{y1} returns the Bessel function of the second kind of order 1 of
1248 is negative, @code{y1} signals a domain error; if it is zero,
1249 @code{y1} signals overflow and returns @math{-@infinity}.
1251 The @code{_Float@var{N}} and @code{_Float@var{N}x} variants are GNU
1264 @code{yn} returns the Bessel function of the second kind of order @var{n} of
1266 is negative, @code{yn} signals a domain error; if it is zero,
1267 @code{yn} signals overflow and returns @math{-@infinity}.
1269 The @code{_Float@var{N}} and @code{_Float@var{N}x} variants are GNU
1299 for certain functions such as @code{sqrt}, @code{fma} and @code{rint}
1308 rounding functions under the names such as @code{crsin} proposed for
1322 direction to the result that is returned to the user. @code{errno}
1328 For the IBM @code{long double} format, as used on PowerPC GNU/Linux,
1337 For the IBM @code{long double} format, functions whose results are
1439 @w{ISO C} interface, @code{rand} and @code{srand}. The SVID functions
1447 * ISO Random:: @code{rand} and friends.
1448 * BSD Random:: @code{random} and friends.
1449 * SVID Random:: @code{drand48} and friends.
1450 * High Quality Random:: @code{arc4random} and friends.
1466 value the @code{rand} function can return. In @theglibc{}, it is
1467 @code{2147483647}, which is the largest signed integer representable in
1468 32 bits. In other libraries, it may be as low as @code{32767}.
1475 The @code{rand} function returns the next pseudo-random number in the
1476 series. The value ranges from @code{0} to @code{RAND_MAX}.
1484 pseudo-random numbers. If you call @code{rand} before a seed has been
1485 established with @code{srand}, it uses the value @code{1} as a default
1489 run, do @code{srand (time (0))}.
1499 This function returns a random number in the range 0 to @code{RAND_MAX}
1500 just as @code{rand} does. However, all its state is stored in the
1502 bits as the type @code{unsigned int} has. This is far too few to
1528 The value returned ranges from @code{0} to @code{2147483647}.
1531 @code{int32_t} value to indicate that the return value always contains
1532 32 bits even if @code{long int} is wider. The standard demands it
1544 The @code{srandom} function sets the state of the random number
1546 of @code{1}, this will cause @code{random} to reproduce the default set
1550 program runs, do @code{srandom (time (0))}.
1556 The @code{initstate} function is used to initialize the random number
1563 You can use this value later as an argument to @code{setstate} to
1570 The @code{setstate} function restores the random number state
1575 You can use this value later as an argument to @code{setstate} to
1578 If the function fails the return value is @code{NULL}.
1598 Objects of type @code{struct random_data} contain the information
1609 The @code{random_r} function behaves exactly like the @code{random}
1617 The @code{srandom_r} function behaves exactly like the @code{srandom}
1625 The @code{initstate_r} function behaves exactly like the @code{initstate}
1633 The @code{setstate_r} function behaves exactly like the @code{setstate}
1660 @var{Y} the state at the end. @code{a} and @code{c} are constants
1669 but they can also be changed by the user. @code{m} is of course 2^48
1684 This function returns a @code{double} value in the range of @code{0.0}
1685 to @code{1.0} (exclusive). The random bits are determined by the global
1688 Since the @code{double} type according to @w{IEEE 754} has a 52-bit
1691 bits and they are initialized to @code{0}.
1699 This function returns a @code{double} value in the range of @code{0.0}
1700 to @code{1.0} (exclusive), similarly to @code{drand48}. The argument is
1711 The @code{lrand48} function returns an integer value in the range of
1712 @code{0} to @code{2^31} (exclusive). Even if the size of the @code{long
1721 This function is similar to the @code{lrand48} function in that it
1722 returns a number in the range of @code{0} to @code{2^31} (exclusive) but
1735 The @code{mrand48} function is similar to @code{lrand48}. The only
1736 difference is that the numbers returned are in the range @code{-2^31} to
1737 @code{2^31} (exclusive).
1743 The @code{jrand48} function is similar to @code{nrand48}. The only
1744 difference is that the numbers returned are in the range @code{-2^31} to
1745 @code{2^31} (exclusive). For the @code{xsubi} parameter the same
1756 The @code{srand48} function sets the most significant 32 bits of the
1759 are initialized to the value @code{0x330E}. Even if the @code{long
1764 like @code{srand48 (time (0))}.
1766 A side-effect of this function is that the values @code{a} and @code{c}
1769 the user has called the @code{lcong48} function (see below).
1775 The @code{seed48} function initializes all 48 bits of the state of the
1779 state, the lower 16 bits of @code{@var{seed16v}[1]} initialize the mid-order
1780 16 bits of the state and the 16 lower bits of @code{@var{seed16v}[2]}
1783 Unlike @code{srand48} this function lets the user initialize all 48 bits
1786 The value returned by @code{seed48} is a pointer to an array containing
1791 As for @code{srand48}, the values @code{a} and @code{c} from the
1802 The @code{lcong48} function allows the user to change the complete state
1803 of the random number generator. Unlike @code{srand48} and
1804 @code{seed48}, this function also changes the constants in the
1808 16 bits of the entries @code{@var{param}[0]} to @code{@var{param}[2]}
1810 @code{@var{param}[3]} to @code{@var{param}[5]} determine the 48 bit
1811 constant @code{a} and @code{@var{param}[6]} determines the 16-bit value
1812 @code{c}.
1828 The user-supplied buffer must be of type @code{struct drand48_data}.
1834 This function is equivalent to the @code{drand48} function with the
1841 If the value is less than @code{0} an error occurred and @code{errno} is
1851 The @code{erand48_r} function works like @code{erand48}, but in addition
1854 @code{xsubi} array, the parameters for the congruential formula from the
1867 This function is similar to @code{lrand48}, but in addition it takes a
1869 just like @code{drand48}.
1881 The @code{nrand48_r} function works like @code{nrand48} in that it
1882 produces a random number in the range @code{0} to @code{2^31}. But instead
1897 This function is similar to @code{mrand48} but like the other reentrant
1911 The @code{jrand48_r} function is similar to @code{jrand48}. Like the
1924 @code{struct drand48_data} should be initialized. The easiest way to do
1947 @code{srand48} does. The state is initialized from the parameter
1960 This function is similar to @code{srand48_r} but like @code{seed48} it
1965 generator like the @code{seed48} function does. If the user wants to
1995 @Theglibc{} uses kernel entropy obtained either through @code{getrandom}
2007 This function returns a single 32-bit value in the range of @code{0} to
2008 @code{2^32−1} (inclusive), which is twice the range of @code{rand} and
2009 @code{random}.
2045 can increase the speed of generated code significantly. The drawback is
2046 that code size will increase, and the increase is not always negligible.
2049 as the library functions and others that might not set @code{errno} and
2052 if the flag @code{-ffast-math} is given to GNU CC.