Update contrib.
1 /** @file ../include/math.h
12 /** @fn finite(double x)
15 The finite finitef and finitel functions return a non-zero value if value is neither
16 infinite nor a "not-a-number" (NaN) value, and 0 otherwise.
27 printf( "finite( %f ) = %d
30 printf( "finitef( %f ) = %d
33 printf( "finitel( %f ) = %d
40 finite ( 1.34565 ) = 1
41 finitef( 1.34565 ) = 1
50 /** @fn finitef(float x)
60 /** @fn acos(double x)
62 @return The acos, acosf, and acosl functions return the arc cosine in the range [0, pi]
64 If: | x | \> 1 , acos (x); returns an NaN.
66 - Detailed description
69 The acos, acosf, and acosl functions compute the principal value of the arc cosine of x .
78 printf( "acos(%f) = %f
81 printf( "acosf(%f) = %f
84 printf( "acosl(%f) = %f
91 acos( -1.000000 ) = 3.14159
92 acosf(-1.000000 ) = 3.14159
93 acosl(-1.000000 ) = 3.14159
111 @externallyDefinedApi
114 /** @fn asin(double x)
116 @return The asin, asinf, and asinl functions return the arc sine in the range
117 -words [-pi/2, +pi/2]
119 If: | x | \> 1 asin (x); returns an NaN.
121 - Detailed description
122 The asin and asinf functions compute the principal value of the arc sine of x .
123 The function asinl is an alias to the function asin. A domain error occurs for arguments not in the range [-1, +1].
131 double y = asin( x );
132 printf( "asin(%f) = %f
135 printf( "asinf(%f) = %f
138 printf( "asinl(%f) = %f
145 asin( 0.500000 ) = 0.523599
146 asinf(0.500000 ) = 0.523599
147 asinl(0.500000 ) = 0.523599
165 @externallyDefinedApi
168 /** @fn atan(double x)
185 @externallyDefinedApi
188 /** @fn atan2(double y, double x)
206 @externallyDefinedApi
209 /** @fn cos(double x)
226 @externallyDefinedApi
229 /** @fn sin(double x)
231 @return The sin and the sinf functions return the sine value.
233 - Detailed description
234 The sin and the sinf functions compute the sine of x (measured in radians).
235 A large magnitude argument may yield a result with little
236 or no significance. sinl is just an alias to the function sin
243 double pi_by_6 = 0.52359877559829887307710723054658383 ;
246 printf( "sin( %f) = %f
249 printf( "sinf( %f) = %f
252 printf( "sinl( %f) = %f
259 sin ( 0.52359877559829887307710723054658383 ) = 0.500000
260 sinf( 0.52359877559829887307710723054658383 ) = 0.500000
261 sinl( 0.52359877559829887307710723054658383 ) = 0.500000
279 @externallyDefinedApi
282 /** @fn tan(double x)
284 @return The tan function returns the tangent value.
286 - Detailed description
287 The tan and tanf functions compute the tangent of x (measured in radians).
288 A large magnitude argument may yield a result
289 with little or no significance.
290 The function tanl is an alias to the function tan
297 double pi_by_4 = 0.7853981633974483096156608458198757;
300 printf( "tan( %f) = %f
303 printf( "tanf( %f) = %f
306 printf( "tanl( %f) = %f
314 tan ( 0.7853981633974483096156608458198757 ) = 1.000000
315 tanf( 0.7853981633974483096156608458198757 ) = 1.000000
316 tanl( 0.7853981633974483096156608458198757; ) =1.000000
334 @externallyDefinedApi
337 /** @fn cosh(double x)
354 @externallyDefinedApi
357 /** @fn sinh(double x)
359 - Detailed description
360 The sinh and the sinhf functions compute the hyperbolic sine of x .
361 The function sinhl is an alias to the function sinh
371 printf( "sinh( %f) = %f
374 printf( "sinhf( %f) = %f
377 printf( "sinhl( %f) = %f
384 sinh ( 0.75 ) = 0.8223167
385 sinhf( 0.75 ) = 0.8223167
386 sinhl( 0.75 ) = 0.8223167
404 @externallyDefinedApi
407 /** @fn tanh(double x)
409 @return The tanh, tanhf and tanhl functions return the hyperbolic tangent value.
411 - Detailed description
412 The tanh and tanhf functions compute the hyperbolic tangent of x . tanhl is an alias to the function tanh.
422 printf( "tanh( %f) = %f
425 printf( "tanhf( %f) = %f
428 printf( "tanhl( %f) = %f
433 printf( "sqrt( %f) = %d
436 printf( "sqrtf( %f) = %d
439 printf( "sqrtl( %f) = %d
446 tanh ( 1.000000 ) = 0.7615941
447 tanhf( 1.000000 ) = 0.7615941
448 tanhl( 1.000000 ) = 0.7615941
466 @externallyDefinedApi
469 /** @fn exp(double x)
471 @return These functions will return the appropriate computation unless an error
472 occurs or an argument is out of range.
473 The functions pow (x, y); and powf (x, y); return an NaN if x \< 0 and y is not an integer.
474 An attempt to take the logarithm of ±0 will return infinity.
475 An attempt to take the logarithm of a negative number will
478 - Detailed description
479 The exp and expf functions compute the base e exponential value of the given argument x .
481 The exp2 and exp2f functions compute the base 2 exponential of the given argument x .
483 The expm1 and expm1f functions compute the value exp(x)-1 accurately even for tiny argument x .
485 The log and logf functions compute the value of the natural logarithm of argument x .
487 The log10 and log10f functions compute the value of the logarithm of argument x to base 10.
489 The log1p and log1pf functions compute
490 the value of log(1+x) accurately even for tiny argument x .
492 The pow and powf functions compute the value
493 of x to the exponent y .
495 Here the long double version APIs are aliases to the double version APIs.
496 All apis \<function\>l behaves similiar to that \<function\>.
506 printf( "exp( %f ) = %f
509 printf( "expf( %f ) = %f
512 printf( "expl( %f ) = %f
516 printf( "exp2( %f ) = %f
519 printf( "exp2f( %f ) = %f
522 printf( "exp2l( %f ) = %f
526 printf( "expm1( %f ) = %f
529 printf( "expm1f( %f ) = %f
532 printf( "expm1l( %f ) = %f
539 exp ( 1.0 ) = 2.718282
540 expf ( 1.0 ) = 2.718282
541 expl ( 1.0 ) = 2.718282
542 exp2 ( 0.0 ) = 1.000000
543 exp2f ( 0.0 ) = 1.000000
544 exp2l ( 0.0 ) = 1.000000
545 expm1 ( 1.0 ) = 1.718281
546 expm1f( 1.0 ) = 1.718281
547 expm1l( 1.0 ) = 1.718281
553 The functions exp(x)-1 and log(1+x) are called
554 expm1 and logp1 in BASIC on the Hewlett-Packard HP -71B and APPLE Macintosh, EXP1 and LN1 in Pascal, exp1 and log1 in C
555 on APPLE Macintoshes, where they have been provided to make
556 sure financial calculations of ((1+x)**n-1)/x, namely
557 expm1(n*log1p(x))/x, will be accurate when x is tiny.
558 They also provide accurate inverse hyperbolic functions. The function pow (x, 0); returns x**0 = 1 for all x including x = 0, oo, and NaN .
559 Previous implementations of pow may
560 have defined x**0 to be undefined in some or all of these
562 Here are reasons for returning x**0 = 1 always: Any program that already tests whether x is zero (or
563 infinite or NaN) before computing x**0 cannot care
564 whether 0**0 = 1 or not.
565 Any program that depends
566 upon 0**0 to be invalid is dubious anyway since that
567 expression's meaning and, if invalid, its consequences
568 vary from one computer system to another. Some Algebra texts (e.g. Sigler's) define x**0 = 1 for
569 all x, including x = 0.
570 This is compatible with the convention that accepts a[0]
571 as the value of polynomial
573 p(x) = a[0]*x**0 + a[1]*x**1 + a[2]*x**2 +...+ a[n]*x**n
576 at x = 0 rather than reject a[0]*0**0 as invalid. Analysts will accept 0**0 = 1 despite that x**y can
577 approach anything or nothing as x and y approach 0
579 The reason for setting 0**0 = 1 anyway is this:
584 functions analytic (expandable
585 in power series) in z around z = 0, and if there
586 x(0) = y(0) = 0, then x(z)**y(z) -> 1 as z -> 0.
590 oo**0 = 1/0**0 = 1 too; and
591 then NaN**0 = 1 too because x**0 = 1 for all finite
592 and infinite x, i.e., independently of x.
599 @externallyDefinedApi
602 /** @fn frexp(double x, int *eptr)
605 @return These functions return the value y ,
606 such that y is a double with magnitude in the interval [1/2, 1]
607 or zero, and x equals y times 2 raised to the power *eptr .
608 If x is zero, both parts of the result are zero.
610 - Detailed description
611 The frexp , frexpf, and frexpl functions break a floating-point number into a normalized
612 fraction and an integral power of 2.
613 They store the integer in the int object pointed to by eptr .
614 As there is no long double is not supported by Symbian, frexpl (is, aliased, to, the); frexp
624 y = frexp( x1, &res; );
625 printf( "frexp(%f , &res;):: Int Part: %d and Fractional Part: %f
627 y = frexpf( x1, &res; );
628 printf( "frexpf(%f , &res;):: Int Part: %d and Fractional Part: %f
630 y = frexpl( x1, &res; );
631 printf( "frexpl(%f , &res;):: Int Part: %d and Fractional Part: %f
638 frexp ( 4.0 , &res; ) :: Int Part: 3 and Fractional Part: 0.5
639 frexpf( 4.0, &res; ) :: Int Part: 3 and Fractional Part: 0.5
640 frexpl( 4.0, &res; ) :: Int Part: 3 and Fractional Part: 0.5
646 @externallyDefinedApi
649 /** @fn ldexp(double x, int n)
652 @return These functions return the value of x times 2 raised to the power n .
654 - Detailed description
655 The ldexp, ldexpf, and ldexpl functions multiply a floating-point number by an integral
663 double x1 = 0.8, x2 = 4, y;
665 printf( "ldexp(%f , %f) = %f
667 y = ldexpf( x1, x2 );
668 printf( "ldexpf(%f , %f) = %f
670 y = ldexpl( x1, x2 );
671 printf( "ldexpl(%f , %f) = %f
678 ldexp ( 0.8, 4 ) = 12.8
679 ldexpf( 0.8, 4 ) = 12.8
680 ldexpl( 0.8, 4 ) = 12.8
691 @externallyDefinedApi
694 /** @fn log(double x)
702 @externallyDefinedApi
705 /** @fn log10(double x)
713 @externallyDefinedApi
716 /** @fn modf(double x, double *iptr)
719 @return The modf, modff and modfl functions return the signed fractional part of a value .
721 - Detailed description
722 The modf function breaks the argument x into integral and fractional parts, each of which has the
723 same sign as the argument.
724 It stores the integral part as a double
725 in the object pointed to by iptr .
726 The function modff (is, the, float, version, of, modf().); The function modfl is an alias to the function modf.
734 double x1 = 123.456703 , y;
737 y = modf( x1, &iptr; );
738 printf( "modf(%f , &iptr;):: Int Part: %f and Fractional Part: %f 0, x1, iptr, y );
739 y = modff( x1, &fptr; );
740 printf( "modff(%f , &iptr;):: Int Part: %f and Fractional Part: %f 0, x1, fptr, y );
741 y = modfl( x1, &iptr; );
742 printf( "modfl(%f , &iptr;):: Int Part: %f and Fractional Part: %f 0, x1, iptr, y );
748 modf ( 123.456703 , &iptr; ) :: Int Part: 123 and Fractional Part: 0.456703
749 modff( 123.456703, &iptr; ) :: Int Part: 123 and Fractional Part: 0.456703
750 modfl( 123.456703, &iptr; ) :: Int Part: 123 and Fractional Part: 0.456703
761 @externallyDefinedApi
764 /** @fn pow(double x, double y)
773 @externallyDefinedApi
776 /** @fn sqrt(double x)
784 @externallyDefinedApi
787 /** @fn ceil(double x)
789 @return x is integral or infinite, x itself is returned.
792 The ceil , ceilf, and ceill functions return the smallest integral value
793 greater than or equal to x ,
794 expressed as a floating-point number.
803 printf( "The ceil of 2.8 is %f
806 printf( "The ceil of -2.8 is %f
809 printf( "The ceilf of 2.8 is %f
812 printf( "The ceilf of -2.8 is %f
815 printf( "The ceill of 2.8 is %f
818 printf( "The ceill of -2.8 is %f
825 The ceil of 2.8 is 3.000000
826 The ceil of -2.8 is -2.000000
827 The ceilf of 2.8 is 3.000000
828 The ceilf of -2.8 is -2.000000
829 The ceill of 2.8 is 3.000000
830 The ceill of -2.8 is -2.000000
846 @externallyDefinedApi
849 /** @fn ceilf(float x)
864 @externallyDefinedApi
867 /** @fn fabs(double x)
869 @return The fabs , fabsf and fabsl functions return the absolute value of x .
871 The fabs , fabsf and fabsl functions compute the absolute value of a floating-point number x .
879 double dx = -3.141593, dy;
881 printf( "fabs( %f ) = %f
884 printf( "fabsf( %f ) = %f
887 printf( "fabsl( %f ) = %f
894 fabs( -3.141593 ) = 3.141593
895 fabsf( -3.141593 ) = 3.141593
896 fabsl( -3.141593 ) = 3.141593
910 @externallyDefinedApi
913 /** @fn fabsf(float x)
926 @externallyDefinedApi
929 /** @fn fabsl(long double x)
942 @externallyDefinedApi
945 /** @fn floor(double x)
947 @return x is integral or infinite, x itself is returned.
950 The floor , floorf, and floorl functions return the largest integral value
951 less than or equal to x ,
952 expressed as a floating-point number.
961 printf( "The floor of 2.8 is %f
964 printf( "The floorf of 2.8 is %f
967 printf( "The floorl of 2.8 is %f
974 The floor of 2.8 is 2.000000
975 The floorf of 2.8 is 2.000000
976 The floorl of 2.8 is 2.000000
992 @externallyDefinedApi
995 /** @fn floorf(float x)
1010 @externallyDefinedApi
1013 /** @fn fmod(double x, double y)
1016 @return The fmod, fmodf, and fmodl functions return the value x - i * y , for some integer i such that, if y is non-zero, the result has the same sign as x and magnitude less than the magnitude of y .
1017 If y is zero, whether a domain error occurs or the fmod and fmodf function returns zero is implementation-defined.
1020 The fmod, fmodf, and fmodl functions compute the floating-point remainder of x / y . fmodl is an alias to the function fmod.
1027 double x1 = 6.5, x2 = 2.25, y;
1029 printf( "fmod(%f , %f) = %f
1031 y = fmodf( x1, x2 );
1032 printf( "fmodf(%f , %f) = %f
1034 y = fmodl( x1, x2 );
1035 printf( "fmodl(%f , %f) = %f
1042 fmod ( 6.4, 2 ) = 2.0
1043 fmodf( 6.4, 2 ) = 2.0
1044 fmodl( 6.4, 2 ) = 2.0
1053 @externallyDefinedApi
1056 /** @fn fmodf(float x, float y)
1065 @externallyDefinedApi
1068 /** @fn acosh(double x)
1070 @return The acosh , acoshf ,
1071 and acoshl functions
1072 return the inverse hyperbolic cosine of x .
1073 If the argument is less than 1, acosh returns an NaN.
1076 The acosh and acoshf functions compute the inverse hyperbolic cosine
1079 The function acoshl is an alias to the function acosh .
1087 double y = acosh( x );
1088 printf( "acosh(%f) = %f
1091 printf( "acoshf(%f) = %f
1094 printf( "acoshl(%f) = %f
1101 acosh( 1.000000 ) = 0.0
1102 acoshf(1.000000 ) = 0.0
1103 acoshl(1.000000 ) = 0.0
1115 @externallyDefinedApi
1118 /** @fn acoshf(float x)
1129 @externallyDefinedApi
1132 /** @fn asinh(double x)
1143 @externallyDefinedApi
1146 /** @fn asinhf(float x)
1157 @externallyDefinedApi
1160 /** @fn atanh(double x)
1171 @externallyDefinedApi
1174 /** @fn atanhf(float x)
1185 @externallyDefinedApi
1188 /** @fn cbrt(double x)
1190 @return The cbrt and cbrtf functions return the requested cube root.
1191 The sqrt and sqrtf functions return the requested square root
1192 unless an error occurs.
1193 An attempt to take the sqrt of negative x causes an NaN to be returned.
1196 The cbrt and cbrtf functions compute
1197 the cube root of x .
1198 The function cbrtl is an alias to the function cbrt.
1200 The sqrt and sqrtf functions compute the
1201 non-negative square root of x.
1202 The function sqrtl is an alias to the function sqrt.
1209 double inp = -0.001;
1212 printf( "cbrt( %f) = %f
1215 printf( "cbrtf( %f) = %f
1218 printf( "cbrtl( %f) = %f
1223 printf( "sqrt( %f) = %d
1226 printf( "sqrtf( %f) = %d
1229 printf( "sqrtl( %f) = %d
1236 cbrt ( -0.001 ) = -0.100000
1237 cbrtf( -0.001 ) = -0.100000
1238 cbrtl( -0.001 ) = -0.100000
1239 sqrt ( 2209.0 ) = 47.0
1240 sqrtf( 2209.0 ) = 47.0
1241 sqrtl( 2209.0 ) = 47.0
1250 @externallyDefinedApi
1253 /** @fn erf(double x)
1261 @externallyDefinedApi
1264 /** @fn erfc(double x)
1272 @externallyDefinedApi
1275 /** @fn erff(float x)
1283 @externallyDefinedApi
1286 /** @fn erfcf(float x)
1294 @externallyDefinedApi
1297 /** @fn exp2(double x)
1305 @externallyDefinedApi
1308 /** @fn exp2f(float x)
1316 @externallyDefinedApi
1319 /** @fn expm1(double)
1321 The expm1 and expm1f functions compute the value exp(x)-1 accurately even for tiny argument x .
1324 @externallyDefinedApi
1327 /** @fn expm1f(float x)
1329 The expm1 and expm1f functions compute the value exp(x)-1 accurately even for tiny argument x .
1338 @externallyDefinedApi
1341 /** @fn fma(double x, double y, double z)
1348 The fma, fmaf, and fmal functions return (x * y) + z, computed with only one rounding error. Using the ordinary multiplication and addition operators, by contrast, results in two roundings: one for the intermediate product and one for the final result.
1349 For instance, the expression 1.2e100 * 2.0e208 - 1.4e308 produces oo due to overflow in the intermediate product, whereas fma(1.2e100, 2.0e208, -1.4e308) returns approximately 1.0e308.
1351 The fused multiply-add operation is often used to improve the accuracy of calculations such as dot products. It may also be used to improve performance on machines that implement it natively. The macros FP_FAST_FMA, FP_FAST_FMAF and FP_FAST_FMAL may be defined in #include \<math.h\>to indicate that fma, fmaf, and fmal (respectively) have comparable or faster speed than a multiply operation followed by an add operation.
1361 double x1 = 1, x2 = 2, x3 =3, y;
1362 y = fma( x1, x2, x3 );
1363 printf( "fma(%f , %f , %f) = %f
1365 y = fmaf( x1, x2, x3 );
1366 printf( "fmaf(%f , %f , %f) = %f
1368 y = fmal( x1, x2, x3 );
1369 printf( "fmal(%f , %f , %f) = %f
1381 Implementation notes In general, these routines will behave as one would expect if x * y + z
1382 were computed with unbounded precision and range,
1383 then rounded to the precision of the return type.
1384 However, on some platforms,
1392 @externallyDefinedApi
1395 /** @fn fmaf(float x, float y, float z)
1405 @externallyDefinedApi
1408 /** @fn fmax(double x, double y)
1412 The fmax, fmaxf, and fmaxl functions return the larger of x and y ,
1413 and likewise, the fmin, fminf, and fminl functions return the smaller of x and y .
1415 as being larger than -0.0.
1416 If one argument is an NaN(Not a Number), then the other argument is returned.
1417 If both arguments are NaN(Not a Number)s, then the result is an NaN(Not a Number).
1426 printf( "fmax ( 0, -9) = %f
1429 printf( "fmaxf( 0, -9) = %f
1432 printf( "fmaxl( 0, -9) = %f
1435 printf( "fmin ( 0, -9) = %f
1438 printf( "fminf ( 0, -9) = %f
1441 printf( "fminl ( 0, -9) = %f
1464 @externallyDefinedApi
1467 /** @fn fmaxf(float x, float y)
1478 @externallyDefinedApi
1481 /** @fn fmaxl(long double x, long double y)
1492 @externallyDefinedApi
1495 /** @fn hypot(double x, double y)
1500 The hypot and hypotf functions
1503 in such a way that underflow will not happen, and overflow
1504 occurs only if the final result deserves it.
1511 double x1 = 3.0 , x2 = 4.0, y;
1512 y = hypot( x1, x2 );
1513 printf( "atan2(%f , %f) = %f
1515 y = hypotf( x1, x2 );
1516 printf( "atan2f(%f , %f) = %f
1518 y = hypotl( x1, x2 );
1519 printf( "hypotl(%f , %f) = %f
1526 hypot ( 3.0, 4.0 ) = 5.000000
1527 hypotf( 3.0, 4.0 ) = 5.000000
1528 hypotl( 3.0, 4.0 ) = 5.000000
1534 As might be expected, hypot (v, NaN);
1536 are NaN for all finite v. But programmers might be surprised at first to discover that hypot (±oo, NaN);
1537 = +oo. This is intentional; it happens because hypot (oo, v);
1538 = +oo for all v, finite or infinite. Hence hypot (oo, v);
1539 is independent of v. Unlike the reserved operand fault on a VAX, the IEEE NaN is designed to disappear when it turns out to be irrelevant, as it does in hypot (oo, NaN);
1544 = +oo for all v, including NaN.
1553 @externallyDefinedApi
1556 /** @fn hypotf(float x, float y)
1566 @externallyDefinedApi
1569 /** @fn ilogb(double x)
1572 The functions ilogb, ilogbf, and ilogbl return x ’s exponent, in integer format. ilogb (±oo);
1574 returns INT_MAX, ilogb (±NaN);
1575 returns FP_ILOGBNAN and ilogb (0);
1585 /*iLogb(), ilogbf() and ilogbl() */
1587 printf( "ilogb( %f) = %f
1590 printf( "ilogbf( %f) = %f
1593 printf( "ilogbl( %f) = %f
1601 ilogb (1024) = 10.000000
1602 ilogbf(1024) = 10.000000
1603 ilogbl(1024) = 10.000000
1615 @externallyDefinedApi
1618 /** @fn ilogbf(float x)
1629 @externallyDefinedApi
1632 /** @fn ilogbl(long double x)
1643 @externallyDefinedApi
1646 /** @fn lgamma(double x)
1654 @externallyDefinedApi
1657 /** @fn lgamma_r(double x, int *signgamp)
1666 @externallyDefinedApi
1669 /** @fn lgammaf(float x)
1677 @externallyDefinedApi
1680 /** @fn lgammaf_r(float x, int *signgamp)
1689 @externallyDefinedApi
1692 /** @fn llrint(double x)
1696 - Detailed description
1697 The lrint function returns the integer nearest to its argument x according to the current rounding mode.
1698 When the rounded result is representable as a long ,
1701 The llrint , llrintf and lrintf functions differ from lrint only in their input and output types. lrintf and llrintl is just an aliases to the functions lrint (and); llrint respectively
1712 printf( "llrint(%f) = %d
1715 printf( "llrintf(%f) = %d
1718 printf( "llrintl(%f) = %d
1721 printf( "lrint(%f) = %d
1724 printf( "lrintf(%f) = %d
1727 printf( "lrintl(%f) = %d
1734 llrint ( 1.4 ) = 1.000000
1735 llrintf( 1.4 ) = 1.000000
1736 llrintl( 1.4 ) = 1.000000
1737 lrint ( 1.4 ) = 1.000000
1738 lrintf( 1.4 ) = 1.000000
1739 lrintl( 0.0 ) = 1.000000
1751 @externallyDefinedApi
1754 /** @fn llrintf(float x)
1765 @externallyDefinedApi
1768 /** @fn llround(double x)
1772 The lround function returns the integer nearest to its argument x ,
1773 rounding away from zero in halfway cases.
1774 If the rounded result is too large to be represented as a long
1775 value, the return value is undefined.
1776 When the rounded result is representable as a long ,
1777 the expression lround (x); is equivalent to round (x);( long) (although the former may be more efficient).
1779 The llround , llroundf , llroundl , lroundf and lroundl functions differ from lround only in their input and output types.
1790 printf( "llround(%f) = %d
1793 printf( "llroundf(%f) = %d
1796 printf( "llroundl(%f) = %d
1800 printf( "lround(%f) = %d
1802 res = lroundf( x1 );
1803 printf( "lroundf(%f) = %d
1805 res = lroundl( x1 );
1806 printf( "lroundl(%f) = %d
1813 llround ( 1.5 ) = 2.000000
1814 llroundf( 1.5 ) = 2.000000
1815 llroundl( 1.5 ) = 2.000000
1816 lround ( 1.5 ) = 2.000000
1817 lroundf( 1.5 ) = 2.000000
1818 lroundl( 1.5 ) = 2.000000
1830 @externallyDefinedApi
1833 /** @fn llroundf(float x)
1844 @externallyDefinedApi
1847 /** @fn log1p(double x)
1855 @externallyDefinedApi
1858 /** @fn log1pf(float x)
1866 @externallyDefinedApi
1869 /** @fn logb(double x)
1871 - Detailed description
1873 These functions allow users to test conformance to -ieee754 .
1874 Their use is not otherwise recommended.
1876 logb (x); and logbf (x); return x 's exponent n ,
1877 a signed integer converted to double-precision floating-point. logb (±oo); = +oo; logb (0); = -oo
1879 scalb (x, n); and scalbf (x, n); return x *(2** n )
1880 computed by exponent manipulation.
1882 significand (x); and significandf (x); return sig ,
1883 where x = sig * 2** n with 1 <= sig <2. significand (x); and significandf (x); are not defined when x is 0, ±oo, or NaN.
1884 Here , long double version function are just aliases to
1885 their corresponding double version apis.
1893 double e = 2.718282;
1894 /*Logb(), logbf() and logbl() */
1896 printf( "logb( %f) = %f
1899 printf( "logbf( %f) = %f
1902 printf( "logbl( %f) = %f
1905 /*scalb(), scalbf() and scalbl()*/
1906 double x1 = 0.8, x2 = 4.0 ;
1907 y = scalb( x1, x2 );
1908 printf( "scalb( %f, %f) = %f
1910 y = scalbf( x1, x2 );
1911 printf( "scalbf( %f, %f) = %f
1913 y = scalbl( x1, x2 );
1914 printf( "scalbl( %f, %f) = %f
1916 /*significand(), significandf() and significandl()*/
1918 y = significand( x2 );
1919 printf( "significand(%f) = %f
1921 y = significandf( x2 );
1922 printf( "significandf(%f) = %f
1924 y = significandl( x2 );
1925 printf( "significandl(%f) = %f
1932 logb( 2.718282) = 1.000000
1933 logbf( 2.718282) = 1.000000
1934 logbl( 2.718282) = 1.000000
1935 scalb( 0.8, 4.0 ) = 12.800000
1936 scalbf( 0.8, 4.0 ) = 12.800000
1937 scalbl( 0.8, 4.0 ) = 12.800000
1938 significand ( 4.0) = 1.000000
1939 significandf( 4.0) = 1.000000
1940 significandl( 4.0) = 1.000000
1950 @externallyDefinedApi
1953 /** @fn logbf(float x)
1962 @externallyDefinedApi
1965 /** @fn lrint(double x)
1976 @externallyDefinedApi
1979 /** @fn lrintf(float x)
1990 @externallyDefinedApi
1993 /** @fn lround(double x)
2004 @externallyDefinedApi
2007 /** @fn lroundf(float x)
2018 @externallyDefinedApi
2021 /** @fn nextafter(double x, double y)
2024 - Detailed description
2026 return the next machine representable number from x in direction y .
2036 y = nextafter( inp1, inp2 );
2037 printf( "nextafter(%f , %f) = %f
2039 y = nextafterf( inp1, inp2 );
2040 printf( "nextafterf(%f , %f) = %f
2042 y = nextafterl( inp1, inp2 );
2043 printf( "nextafterl(%f , %f) = %f
2048 y = nexttoward( inp1, inp2 );
2049 printf( "nexttoward(%f , %f) = %f
2051 y = nexttowardf( inp1, inp2 );
2052 printf( "nexttowardf(%f , %f) = %f
2054 y = nexttowardl( inp1, inp2 );
2055 printf( "nexttowardl(%f , %f) = %f
2062 nextafter ( 1.3, 2.0 ) = 1.3
2063 nextafterf ( 1.3, 2.0 ) = 1.3
2064 nextafterl ( 1.3, 2.0 ) = 1.3
2065 nexttoward ( 9, 9 ) = 9
2066 nexttowardf ( 9, 9 ) = 9
2067 nexttowardl ( 9, 9 ) = 9
2077 @externallyDefinedApi
2080 /** @fn nextafterf(float x, float y)
2090 @externallyDefinedApi
2093 /** @fn remainder(double x, double p)
2104 @externallyDefinedApi
2107 /** @fn remainderf(float x, float p)
2118 @externallyDefinedApi
2121 /** @fn remquo(double x, double y, int *quo)
2133 @externallyDefinedApi
2136 /** @fn remquof(float x, float y, int *quo)
2148 @externallyDefinedApi
2151 /** @fn rint(double x)
2167 @externallyDefinedApi
2170 /** @fn rintf(float x)
2186 @externallyDefinedApi
2189 /** @fn j0(double x)
2191 @return If these functions are successful,
2192 the computed value is returned.
2194 - Detailed description
2195 The functions j0 , j0f , j1 and j1f compute the Bessel function of the first kind of the order 0 and the order 1, respectively,
2198 the functions jn and jnf compute the Bessel function of the first kind of the integer order n for the real value x .
2200 The functions y0 , y0f , y1 ,
2201 and y1f compute the linearly independent Bessel function of the second kind of the order 0 and the order 1, respectively,
2203 positive real value x ;
2204 the functions yn and ynf compute the Bessel function of the second kind for the integer order n for the positive real value x .
2206 Here the long double version APIs are aliases the double version APIs.
2207 All APIs \<Function\>l behaves similiar to that of \<Function\>.
2215 /*J0(), j0f() and j0l() */
2217 printf( "j0( %f) = %f
2220 printf( "j0f( %f) = %f
2223 printf( "j0l( %f) = %f
2226 /*J1(), j1f() and j1l() */
2228 printf( "j1( %f) = %f
2231 printf( "j1f( %f) = %f
2234 printf( "j1l( %f) = %f
2237 /*jn(), jnf() and jnl() */
2239 printf( "jn( 2, %f) = %f
2242 printf( "jnf( 1, %f) = %f
2244 y = jnl( 10, 0.75 );
2245 printf( "jnl(10, %f) = %f
2248 /*y0(), y0f() and y0l() */
2250 printf( "y0( %f) = %f
2253 printf( "y0f( %f) = %f
2256 printf( "y0l( %f) = %f
2259 /*y1(), y1f() and y1l() */
2261 printf( "y1( %f) = %f
2264 printf( "y1f( %f) = %f
2267 printf( "y1l( %f) = %f
2270 /*yn(), ynf() and ynl() */
2272 printf( "yn( 2, %f) = %f
2275 printf( "ynf( 1, %f) = %f
2277 y = ynl( 10, 0.75 );
2278 printf( "ynl(10, %f) = %f
2286 j0( 1.000) = 0.76519768
2287 j0f( 1.000) = 0.76519768
2288 j0l( 1.000) = 0.76519768
2289 j1 ( 1.000) = 0.4400505
2290 j1f( 1.000) = 0.4400505
2291 j1l( 1.000) = 0.4400505
2292 jn ( 3, 1.000) = 0.0195633
2293 jnf( 1, 1.000) = 0.4400505
2294 jnl( 10, 0.75) = 0.1496212
2295 y0 ( 1.000) = 0.0882569
2296 y0f( 1.000) = 0.0882569
2297 y0l( 1.000) = 0.0882569
2298 y1 ( 1.000) = -0.7812128
2299 y1f( 1.000) = -0.7812128
2300 y1l( 1.000) = -0.7812128
2301 yn ( 3, 1.000) = -5.8215176
2302 ynf( 1, 1.000) = -0.781212
2303 ynl( 10, 0.75) = -2133501638.9
2312 @externallyDefinedApi
2315 /** @fn j0f(float x)
2323 @externallyDefinedApi
2326 /** @fn j1(double x)
2334 @externallyDefinedApi
2337 /** @fn j1f(float x)
2345 @externallyDefinedApi
2348 /** @fn jn(int n, double x)
2357 @externallyDefinedApi
2360 /** @fn jnf(int n, float x)
2369 @externallyDefinedApi
2372 /** @fn scalb(double x, double fn)
2382 @externallyDefinedApi
2385 /** @fn scalbf(float x, float fn)
2395 @externallyDefinedApi
2398 /** @fn scalbln(double x, long n)
2401 @return x (*, FLT_RADIX**n); ±HUGE_VAL, (±HUGE_VALF,, and, ±HUGE_VALL); (according to the sign of x ) as appropriate for the return type of the function. x is NaN , a shall be returned. x is ±0 or ±Inf, x shall be returned. n is 0, x shall be returned.
2403 - Detailed description
2404 These routines return x *(2** n )
2405 computed by exponent manipulation.
2412 /*scalbn(), scalbnf() and scalbnl()*/
2413 double x1 = 0.8, x2 = 4.0 ;
2414 y = scalbn( x1, x2 );
2415 printf( "scalbn( %f, %f) = %f
2417 y = scalbnf( x1, x2 );
2418 printf( "scalbnf( %f, %f) = %f
2420 y = scalbnl( x1, x2 );
2421 printf( "scalbnl( %f, %f) = %f
2423 /*scalbln(), scalblnf() and scalblnl()*/
2424 x1 = 0.8, x2 = 4.0 ;
2425 y = scalbln( x1, x2 );
2426 printf( "scalbln( %f, %f) = %f
2428 y = scalblnf( x1, x2 );
2429 printf( "scalblnf( %f, %f) = %f
2431 y = scalblnl( x1, x2 );
2432 printf( "scalblnl( %f, %f) = %f
2439 scalbn ( 0.8, 4.0 ) = 12.800000
2440 scalbnf( 0.8, 4.0 ) = 12.800000
2441 scalbnl( 0.8, 4.0 ) = 12.800000
2442 scalbln ( 0.8, 4.0 ) = 12.800000
2443 scalblnf( 0.8, 4.0 ) = 12.800000
2444 scalblnl( 0.8, 4.0 ) = 12.800000
2454 @externallyDefinedApi
2457 /** @fn scalblnf(float x, long n)
2467 @externallyDefinedApi
2470 /** @fn scalblnl(long double x, long n)
2480 @externallyDefinedApi
2483 /** @fn scalbn(double x, int n)
2493 @externallyDefinedApi
2496 /** @fn scalbnf(float x, int n)
2506 @externallyDefinedApi
2509 /** @fn y0(double x)
2517 @externallyDefinedApi
2520 /** @fn y0f(float x)
2528 @externallyDefinedApi
2531 /** @fn y1(double x)
2539 @externallyDefinedApi
2542 /** @fn y1f(float x)
2550 @externallyDefinedApi
2553 /** @fn yn(int n, double x)
2562 @externallyDefinedApi
2565 /** @fn ynf(int n, float x)
2574 @externallyDefinedApi
2577 /** @fn gamma(double x)
2585 @externallyDefinedApi
2588 /** @fn gammaf(float x)
2596 @externallyDefinedApi
2599 /** @fn copysign(double x, double y)
2602 - Detailed description
2603 The copysign , copysignf, and copysignl functions
2604 return x with its sign changed to y 's .
2611 double x1 = 0, x2 = -4, y;
2612 y = copysign( x1, x2 );
2613 printf( "copysign(%f , %f) = %f
2615 y = copysignf( x1, x2 );
2616 printf( "copysignf(%f , %f) = %f
2618 y = copysignl( x1, x2 );
2619 printf( "copysignl(%f , %f) = %f
2626 copysign ( 0, -4 ) = -0.0
2627 copysignf( 0, -4 ) = -0.0
2628 copysignl( 0, -4 ) = -0.0
2640 @externallyDefinedApi
2643 /** @fn copysignf(float x, float y)
2655 @externallyDefinedApi
2658 /** @fn copysignl(long double x, long double y)
2670 @externallyDefinedApi
2673 /** @fn fdim(double x, double y)
2676 - Detailed description
2677 The fdim, fdimf, and fdiml functions return the positive difference between x and y .
2678 That is, if x- y is positive, then x- y is returned.
2679 If either x or y is an NaN, then an NaN is returned.
2680 Otherwise, the result is +0.0.
2687 double x1 = 0, x2 = -9, y;
2689 printf( "fdim(%f , %f) = %f
2691 y = fdimf( x1, x2 );
2692 printf( "fdimf(%f , %f) = %f
2694 y = fdiml( x1, x2 );
2695 printf( "fdiml(%f , %f) = %f
2715 @externallyDefinedApi
2718 /** @fn fdimf(float x, float y)
2729 @externallyDefinedApi
2732 /** @fn fdiml(long double x, long double y)
2743 @externallyDefinedApi
2746 /** @fn fmin(double x, double y)
2757 @externallyDefinedApi
2760 /** @fn fminf(float x, float y)
2771 @externallyDefinedApi
2774 /** @fn nearbyint(double x)
2776 @return x is integral or infinite, x itself is returned.
2778 - Detailed description
2779 The rint and rintf functions return the integral value nearest to x according to the prevailing rounding mode.
2781 The nearbyint and nearbyintf functions perform the same operation.
2782 The functions nearbyintl and rintl are aliases to the functions nearbyint and rint respectively.
2791 y = nearbyint( inp );
2792 printf( "nearbyint(%f ) = %f
2794 y = nearbyintf( inp );
2795 printf( "nearbyintf(%f ) = %f
2797 y = nearbyintl( inp );
2798 printf( "nearbyintl(%f ) = %f
2802 printf( "rint(%f ) = %f
2805 printf( "rintf(%f ) = %f
2808 printf( "rintl(%f ) = %f
2816 nearbyint ( 1.5 ) = 2.000000
2817 nearbyintf ( 1.5 ) = 2.000000
2818 nearbyintl ( 1.5 ) = 2.000000
2819 rint ( 1.5 ) = 2.000000
2820 rintf( 1.5 ) = 2.000000
2821 rintl( 1.5 ) = 2.000000
2838 @externallyDefinedApi
2841 /** @fn nearbyintf(float x)
2857 @externallyDefinedApi
2860 /** @fn round(double x)
2862 @return x is integral or infinite, x itself is returned.
2864 - Detailed description
2865 The round , roundf ,
2866 and roundl functions return the nearest integral value to x ;
2867 if x lies halfway between two integral values, then these
2868 functions return the integral value with the larger
2869 absolute value (i.e., they round away from zero).
2879 printf( "round(%f ) = %f
2882 printf( "roundf(%f ) = %f
2885 printf( "roundl(%f ) = %f
2893 round ( 0.5 ) = 1.000000
2894 roundf ( 0.5 ) = 1.000000
2895 roundl ( 0.5 ) = 1.000000
2911 @externallyDefinedApi
2914 /** @fn roundf(float x)
2929 @externallyDefinedApi
2932 /** @fn trunc(double x)
2934 @return x is integral, infinite or NaN , x itself is returned.
2936 - Detailed description
2937 The trunc , truncf ,
2938 and truncl functions return the nearest integral value with magnitude less than
2940 They are equivalent to rint , rintf ,
2942 respectively, in the FE_TOWARDZERO rounding mode.
2949 double inp = 1048580.625;
2952 printf( "trunc( %f) = %f
2955 printf( "truncf( %f) = %f
2958 printf( "truncl( %f) = %f
2966 trunc ( 1048580.625 ) = 1048580.000000
2967 truncf( 1048580.625 ) = 1048580.000000
2968 truncl( 1048580.625 ) = 1048580.000000
2983 @externallyDefinedApi
2986 /** @fn truncf(float x)
3000 @externallyDefinedApi
3003 /** @fn truncl(long double x)
3017 @externallyDefinedApi
3020 /** @fn drem(double x, double y)
3023 @return The drem() function returns the remainder, unless y is zero.
3025 - Detailed description
3026 The drem dremf and the dreml functions compute the remainder of dividing x by y. The
3027 return value is x - n * y, where n is the quotient of x / y, rounded to
3028 the nearest integer. If the quotient is 1/2, it is rounded to the even
3030 The function dreml an alias to the function drem.
3037 double x1 = 6.4, x2 = 2, y;
3039 printf( "drem(%f , %f) = %f
3041 y = dremf( x1, x2 );
3042 printf( "dremf(%f , %f) = %f
3044 y = dreml( x1, x2 );
3045 printf( "dreml(%f , %f) = %f
3052 drem ( 6.4, 2 ) = 0.4
3053 dremf( 6.4, 2 ) = 0.4
3054 dreml( 6.4, 2 ) = 0.4
3060 @externallyDefinedApi
3063 /** @fn isnanf(float)
3065 test for infinity or not-a-number
3068 @externallyDefinedApi
3071 /** @fn significand(double x)
3080 @externallyDefinedApi
3083 /** @fn significandf(float x)
3092 @externallyDefinedApi
3095 /** @fn acosf(float x)
3112 @externallyDefinedApi
3115 /** @fn asinf(float x)
3132 @externallyDefinedApi
3135 /** @fn atanf(float x)
3152 @externallyDefinedApi
3155 /** @fn atan2f(float y, float x)
3173 @externallyDefinedApi
3176 /** @fn cosf(float x)
3193 @externallyDefinedApi
3196 /** @fn sinf(float x)
3213 @externallyDefinedApi
3216 /** @fn tanf(float x)
3233 @externallyDefinedApi
3236 /** @fn coshf(float x)
3253 @externallyDefinedApi
3256 /** @fn sinhf(float x)
3273 @externallyDefinedApi
3276 /** @fn tanhf(float x)
3293 @externallyDefinedApi
3296 /** @fn expf(float x)
3304 @externallyDefinedApi
3307 /** @fn frexpf(float x, int *eptr)
3315 @externallyDefinedApi
3318 /** @fn log10f(float x)
3326 @externallyDefinedApi
3329 /** @fn logf(float x)
3337 @externallyDefinedApi
3340 /** @fn modff(float x, float *iptr)
3351 @externallyDefinedApi
3354 /** @fn powf(float x, float y)
3363 @externallyDefinedApi
3366 /** @fn sqrtf(float x)
3374 @externallyDefinedApi
3377 /** @fn cbrtf(float x)
3385 @externallyDefinedApi
3388 /** @fn nexttowardf(float x, long double y)
3398 @externallyDefinedApi
3403 A positive double expression, not necessarily representable as a float.
3404 Used as an error value returned by the mathematics library. HUGE_VAL evaluates to positive infinity on systems supporting the ANSI/IEEE Std 754:1985 standard.
3407 @externallyDefinedApi
3412 The value of FP_ILOGB0 shall be either INT_MIN or - INT_MAX.
3415 @externallyDefinedApi
3418 /** @def FP_ILOGBNAN
3420 The value of FP_ILOGBNAN shall be either INT_MAX or INT_MIN.
3423 @externallyDefinedApi
3428 A positive long double constant expression. Used as an error value returned by the mathematics library.
3431 @externallyDefinedApi
3436 A positive float constant expression. Used as an error value returned by the mathematics library.
3439 @externallyDefinedApi
3444 A constant expression of type float representing positive or unsigned infinity, if available;
3445 else a positive constant of type float that overflows at translation time.
3448 @externallyDefinedApi
3453 A constant expression of type float representing a quiet NaN.
3454 This symbolic constant is only defined if the implementation supports quiet NaNs for the float type.
3457 @externallyDefinedApi
3462 macro shall expand to the integer constants 1
3465 @externallyDefinedApi
3468 /** @def MATH_ERREXCEPT
3470 macro shall expand to the integer constants 1
3473 @externallyDefinedApi
3476 /** @def math_errhandling
3478 Macro shall expand to an expression that has type int and the value MATH_ERRNO, MATH_ERREXCEPT, or the bitwise-inclusive OR of both
3481 @externallyDefinedApi
3484 /** @def FP_INFINITE
3486 Macro shall be defined for number classification. They represent the mutually-exclusive kinds of floating-point values.
3487 They expand to integer constant expressions with distinct values.
3488 Additional implementation-defined floating-point classifications, with macro definitions beginning with FP_ and an uppercase letter, may also be specified by the implementation.
3491 @externallyDefinedApi
3496 Macro shall be defined for number classification. They represent the mutually-exclusive kinds of floating-point values.
3497 They expand to integer constant expressions with distinct values.
3498 Additional implementation-defined floating-point classifications, with macro definitions beginning with FP_ and an uppercase letter, may also be specified by the implementation.
3501 @externallyDefinedApi
3506 Macro shall be defined for number classification. They represent the mutually-exclusive kinds of floating-point values.
3507 They expand to integer constant expressions with distinct values.
3508 Additional implementation-defined floating-point classifications, with macro definitions beginning with FP_ and an uppercase letter, may also be specified by the implementation.
3511 @externallyDefinedApi
3514 /** @def FP_SUBNORMAL
3516 Macro shall be defined for number classification. They represent the mutually-exclusive kinds of floating-point values.
3517 They expand to integer constant expressions with distinct values.
3518 Additional implementation-defined floating-point classifications, with macro definitions beginning with FP_ and an uppercase letter, may also be specified by the implementation.
3521 @externallyDefinedApi
3526 Macro shall be defined for number classification. They represent the mutually-exclusive kinds of floating-point values.
3527 They expand to integer constant expressions with distinct values.
3528 Additional implementation-defined floating-point classifications, with macro definitions beginning with FP_ and an uppercase letter, may also be specified by the implementation.
3531 @externallyDefinedApi
3534 /** @def fpclassify(x)
3536 The math.h header shall define the following macros, where real floating indicates that the argument shall be an expression of real floating type
3539 @externallyDefinedApi
3542 /** @def isfinite(x)
3544 The math.h header shall define the following macros, where real floating indicates that the argument shall be an expression of real floating type
3547 @externallyDefinedApi
3552 The math.h header shall define the following macros, where real floating indicates that the argument shall be an expression of real floating type
3555 @externallyDefinedApi
3560 The math.h header shall define the following macros, where real floating indicates that the argument shall be an expression of real floating type
3563 @externallyDefinedApi
3566 /** @def isnormal(x)
3568 The math.h header shall define the following macros, where real floating indicates that the argument shall be an expression of real floating type
3571 @externallyDefinedApi
3574 /** @def isgreater(x, y)
3576 The math.h header shall define the following macros, where real floating indicates that the argument shall be an expression of real floating type
3579 @externallyDefinedApi
3582 /** @def isless(x, y)
3584 The math.h header shall define the following macros, where real floating indicates that the argument shall be an expression of real floating type
3587 @externallyDefinedApi
3590 /** @def islessequal(x, y)
3592 The math.h header shall define the following macros, where real floating indicates that the argument shall be an expression of real floating type
3595 @externallyDefinedApi
3598 /** @def islessgreater(x, y)
3600 The math.h header shall define the following macros, where real floating indicates that the argument shall be an expression of real floating type
3603 @externallyDefinedApi
3606 /** @def isunordered(x, y)
3608 The math.h header shall define the following macros, where real floating indicates that the argument shall be an expression of real floating type
3611 @externallyDefinedApi
3614 /** @def isgreaterequal(x, y)
3616 The math.h header shall define the following macros, where real floating indicates that the argument shall be an expression of real floating type
3619 @externallyDefinedApi
3624 The math.h header shall define the following macros, where real floating indicates that the argument shall be an expression of real floating type
3627 @externallyDefinedApi
3632 Defines the Value of e
3635 @externallyDefinedApi
3640 Defines the Value of log2e
3643 @externallyDefinedApi
3648 Defines the Value of log10e
3651 @externallyDefinedApi
3656 Defines the Value of loge2
3659 @externallyDefinedApi
3664 Defines the Value of loge10
3667 @externallyDefinedApi
3672 Defines the Value of pi
3675 @externallyDefinedApi
3680 Defines the Value of pi/2
3683 @externallyDefinedApi
3688 Defines the Value of pi/4
3691 @externallyDefinedApi
3696 Defines the Value of 1/pi
3699 @externallyDefinedApi
3704 Defines the Value of 2/pi
3707 @externallyDefinedApi
3712 Defines the Value of 2/sqrt(pi)
3715 @externallyDefinedApi
3720 Defines the Value of sqrt(2)
3723 @externallyDefinedApi
3728 Defines the Value of 1/sqrt(2)
3731 @externallyDefinedApi
3736 Value of maximum non-infinite single-precision floating point number.
3739 @externallyDefinedApi
3744 Defines to (float)3.40282346638528860e+38
3747 @externallyDefinedApi
3750 /** @typedef typedef __double_t double_t;
3755 @externallyDefinedApi
3758 /** @typedef typedef __float_t float_t;
3763 @externallyDefinedApi