赞
踩
#include <stdio.h>
#include <math.h>
#define PI 3.14159265
int main ()
{
double param, result;
param = 60.0;
result = cos ( param * PI / 180.0 );
printf ("The cosine of %f degrees is %f.\n", param, result );
return 0;
}
The cosine of 60.000000 degrees is 0.500000.
#include <stdio.h>
#include <math.h>
#define PI 3.14159265
int main()
{
double param, result;
param = 30.0;
result = sin(param * PI / 180);
printf("The sine of %f degrees is %f.\n", param, result);
return 0;
}
The sine of 30.000000 degrees is 0.500000.
#include <stdio.h>
#include <cmath>
#define PI 3.14159265
int main()
{
double param, result;
param = 45.0;
result = tan(param * PI / 180.0);
printf("The tangent of %f degrees is %f.\n", param, result);
return 0;
}
The tangent of 45.000000 degrees is 1.000000.
#include <iostream>
#include <cmath>
#define PI 3.14159265
int main()
{
double param, result;
param = 0.5;
result = acos(param) * 180.0 / PI;
printf("The arc cosine of %f is %f degrees.\n", param, result);
return 0;
}
The arc cosine of 0.500000 is 60.000000 degrees.
#include <iostream>
#include <cmath>
#define PI 3.14159265
int main()
{
double param, result;
param = 0.5;
result = asin(param) * 180.0 / PI;
printf("The arc sine of %f is %f degrees\n", param, result);
return 0;
}
The arc sine of 0.500000 is 30.000000 degrees
#include <iostream>
#include <cmath>
#define PI 3.14159265
int main()
{
double param, result;
param = 1.0;
result = atan(param) * 180 / PI;
printf("The arc tangent of %f is %f degrees\n", param, result);
return 0;
}
The arc tangent of 1.000000 is 45.000000 degrees
#include <iostream>
#include <cmath>
#define PI 3.14159265
int main()
{
double x, y, result;
x = -10.0;
y = 10.0;
result = atan2(y, x) * 180 / PI;
printf("The arc tangent for (x=%f, y=%f) is %f degrees\n", x, y, result);
return 0;
}
The arc tangent for (x=-10.000000, y=10.000000) is 135.000000 degrees
#include <iostream>
#include <cmath>
int main()
{
double param, result;
param = log(2.0);
result = cosh(param);
printf("The hyperbolic cosine of %f is %f.\n", param, result);
return 0;
}
The hyperbolic cosine of 0.693147 is 1.250000.
#include <iostream>
#include <cmath>
int main()
{
double param, result;
param = log(2.0);
result = sinh(param);
printf("The hyperbolic sine of %f is %f.\n", param, result);
return 0;
}
The hyperbolic sine of 0.693147 is 0.750000.
#include <iostream>
#include <cmath>
int main()
{
double param, result;
param = log(2.0);
result = tanh(param);
printf("The hyperbolic tangent of %f is %f.\n", param, result);
return 0;
}
The hyperbolic tangent of 0.693147 is 0.600000.
#include <iostream>
#include <cmath>
int main()
{
double param, result;
param = exp(2) - sinh(2);
result = acosh(param);
printf("The area hyperbolic cosine of %f is %f radians.\n", param, result);
return 0;
}
The area hyperbolic cosine of 3.762196 is 2.000000 radians.
#include <iostream>
#include <cmath>
int main()
{
double param, result;
param = exp(2) - cosh(2);
result = asinh(param);
printf("The area hyperbolic sine of %f is %f.\n", param, result);
return 0;
}
The area hyperbolic sine of 3.626860 is 2.000000.
#include <iostream>
#include <cmath>
int main()
{
double param, result;
param = tanh(1);
result = atanh(param);
printf("The area hyperbolic tangent of %f is %f.\n", param, result);
return 0;
}
The area hyperbolic tangent of 0.761594 is 1.000000.
#include <iostream>
#include <cmath>
int main ()
{
double param, result;
param = 5.0;
result = exp (param);
printf ("The exponential value of %f is %f.\n", param, result );
return 0;
}
The exponential value of 5.000000 is 148.413159.
exponent
存储在exp指向的位置,significand
是函数返回的值。#include <iostream>
#include <cmath>
int main ()
{
double param, result;
int n;
param = 8.0;
result = frexp (param , &n);
printf ("%f = %f * 2^%d\n", param, result, n);
return 0;
}
8.000000 = 0.500000 * 2^4
#include <iostream>
#include <cmath>
int main ()
{
double param, result;
int n;
param = 0.95;
n = 4;
result = ldexp (param , n);
printf ("%f * 2^%d = %f\n", param, n, result);
return 0;
}
0.950000 * 2^4 = 15.200000
#include <iostream>
#include <cmath>
int main ()
{
double param, result;
param = 5.5;
result = log (param);
printf ("log(%f) = %f\n", param, result );
return 0;
}
log(5.500000) = 1.704748
#include <iostream>
#include <cmath>
int main ()
{
double param, result;
param = 1000.0;
result = log10 (param);
printf ("log10(%f) = %f\n", param, result );
return 0;
}
log10(1000.000000) = 3.000000
#include <iostream>
#include <cmath>
int main ()
{
double param, fractpart, intpart;
param = 3.14159265;
fractpart = modf (param , &intpart);
printf ("%f = %f + %f \n", param, intpart, fractpart);
return 0;
}
3.141593 = 3.000000 + 0.141593
#include <iostream>
#include <cmath>
int main ()
{
double param, result;
param = 8.0;
result = exp2 (param);
printf ("2 ^ %f = %f.\n", param, result );
return 0;
}
2 ^ 8.000000 is 256.000000.
#include <iostream>
#include <cmath>
int main()
{
double param, result;
param = 1.0;
result = expm1(param);
printf("expm1 (%f) = %f.\n", param, result);
return 0;
}
expm1 (1.000000) = 1.718282.
#include <iostream>
#include <cmath>
int main ()
{
double param;
int result;
param = 10.0;
result = ilogb (param);
printf ("ilogb(%f) = %d\n", param, result);
return 0;
}
ilogb(10.000000) = 3
#include <iostream>
#include <cmath>
int main ()
{
double param, result;
param = 1.0;
result = log1p (param);
printf ("log1p (%f) = %f.\n", param, result );
return 0;
}
log1p (1.000000) = 0.693147
#include <iostream>
#include <cmath>
int main ()
{
double param, result;
param = 1024.0;
result = log2 (param);
printf ("log2 (%f) = %f.\n", param, result );
return 0;
}
log2 (1024.000000) = 10.000000
#include <iostream>
#include <cmath>
int main ()
{
double param, result;
param = 1024.0;
result = logb (param);
printf ("logb (%f) = %f.\n", param, result );
return 0;
}
logb (1024.000000) = 10.000000
#include <iostream>
#include <cmath>
int main ()
{
double param, result;
int n;
param = 1.50;
n = 4;
result = scalbn (param , n);
printf ("%f * %d^%d = %f\n", param, FLT_RADIX, n, result);
return 0;
}
1.500000 * 2^4 = 24.000000
long int
类型#include <iostream>
#include <cmath>
int main ()
{
double param, result;
long n;
param = 1.50;
n = 4L;
result = scalbln (param , n);
printf ("%f * %d^%d = %f\n", param, FLT_RADIX, n, result);
return 0;
}
1.500000 * 2^4 = 24.000000
#include <iostream>
#include <cmath>
int main ()
{
printf ("7 ^ 3 = %f\n", pow (7.0, 3.0) );
printf ("4.73 ^ 12 = %f\n", pow (4.73, 12.0) );
printf ("32.01 ^ 1.54 = %f\n", pow (32.01, 1.54) );
return 0;
}
7 ^ 3 = 343.000000
4.73 ^ 12 = 125410439.217423
32.01 ^ 1.54 = 208.036691
#include <iostream>
#include <cmath>
int main ()
{
double param, result;
param = 1024.0;
result = sqrt (param);
printf ("sqrt(%f) = %f\n", param, result );
return 0;
}
sqrt(1024.000000) = 32.000000
#include <iostream>
#include <cmath>
int main ()
{
double param, result;
param = 27.0;
result = cbrt (param);
printf ("cbrt (%f) = %f\n", param, result);
return 0;
}
cbrt (27.000000) = 3.000000
#include <iostream>
#include <cmath>
int main()
{
double leg_x, leg_y, result;
leg_x = 3;
leg_y = 4;
result = hypot(leg_x, leg_y);
printf("%f, %f and %f form a right-angled triangle.\n", leg_x, leg_y, result);
return 0;
}
3.000000, 4.000000 and 5.000000 form a right-angled triangle.
#include <iostream>
#include <cmath>
int main ()
{
double param, result;
param = 1.0;
result = erf (param);
printf ("erf (%f) = %f\n", param, result );
return 0;
}
erf (1.000000) = 0.842701
#include <iostream>
#include <cmath>
int main ()
{
double param, result;
param = 1.0;
result = erfc (param);
printf ("erfc(%f) = %f\n", param, result );
return 0;
}
erfc (1.000000) = 0.157299
#include <iostream>
#include <cmath>
int main ()
{
double param, result;
param = 0.5;
result = tgamma (param);
printf ("tgamma(%f) = %f\n", param, result );
return 0;
}
tgamma (0.500000) = 1.772454
#include <iostream>
#include <cmath>
int main ()
{
double param, result;
param = 0.5;
result = lgamma (param);
printf ("lgamma(%f) = %f\n", param, result );
return 0;
}
lgamma (0.500000) = 0.572365
#include <iostream>
#include <cmath>
int main ()
{
printf ( "ceil of 2.3 is %.1f\n", ceil(2.3) );
printf ( "ceil of 3.8 is %.1f\n", ceil(3.8) );
printf ( "ceil of -2.3 is %.1f\n", ceil(-2.3) );
printf ( "ceil of -3.8 is %.1f\n", ceil(-3.8) );
return 0;
}
ceil of 2.3 is 3.0
ceil of 3.8 is 4.0
ceil of -2.3 is -2.0
ceil of -3.8 is -3.0
#include <iostream>
#include <cmath>
int main ()
{
printf ( "floor of 2.3 is %.1lf\n", floor (2.3) );
printf ( "floor of 3.8 is %.1lf\n", floor (3.8) );
printf ( "floor of -2.3 is %.1lf\n", floor (-2.3) );
printf ( "floor of -3.8 is %.1lf\n", floor (-3.8) );
return 0;
}
floor of 2.3 is 2.0
floor of 3.8 is 3.0
floor of -2.3 is -3.0
floor of -3.8 is -4.0
#include <iostream>
#include <cmath>
int main ()
{
printf ( "fmod of 5.3 / 2 is %f\n", fmod (5.3,2) );
printf ( "fmod of 18.5 / 4.2 is %f\n", fmod (18.5,4.2) );
return 0;
}
fmod of 5.3 / 2 is 1.300000
fmod of 18.5 / 4.2 is 1.700000
#include <iostream>
#include <cmath>
int main ()
{
const char * format = "%.1f \t%.1f \t%.1f \t%.1f \t%.1f\n";
printf ("value\tround\tfloor\tceil\ttrunc\n");
printf ("-----\t-----\t-----\t----\t-----\n");
printf (format, 2.3,round( 2.3),floor( 2.3),ceil( 2.3),trunc( 2.3));
printf (format, 3.8,round( 3.8),floor( 3.8),ceil( 3.8),trunc( 3.8));
printf (format, 5.5,round( 5.5),floor( 5.5),ceil( 5.5),trunc( 5.5));
printf (format,-2.3,round(-2.3),floor(-2.3),ceil(-2.3),trunc(-2.3));
printf (format,-3.8,round(-3.8),floor(-3.8),ceil(-3.8),trunc(-3.8));
printf (format,-5.5,round(-5.5),floor(-5.5),ceil(-5.5),trunc(-5.5));
return 0;
}
#include <iostream>
#include <cmath>
int main ()
{
const char * format = "%.1f \t%.1f \t%.1f \t%.1f \t%.1f\n";
printf ("value\tround\tfloor\tceil\ttrunc\n");
printf ("-----\t-----\t-----\t----\t-----\n");
printf (format, 2.3,round( 2.3),floor( 2.3),ceil( 2.3),trunc( 2.3));
printf (format, 3.8,round( 3.8),floor( 3.8),ceil( 3.8),trunc( 3.8));
printf (format, 5.5,round( 5.5),floor( 5.5),ceil( 5.5),trunc( 5.5));
printf (format,-2.3,round(-2.3),floor(-2.3),ceil(-2.3),trunc(-2.3));
printf (format,-3.8,round(-3.8),floor(-3.8),ceil(-3.8),trunc(-3.8));
printf (format,-5.5,round(-5.5),floor(-5.5),ceil(-5.5),trunc(-5.5));
return 0;
}
long int
类型的值返回。#include <iostream>
#include <cmath>
int main ()
{
printf ( "lround (2.3) = %ld\n", lround(2.3) );
printf ( "lround (3.8) = %ld\n", lround(3.8) );
printf ( "lround (-2.3) = %ld\n", lround(-2.3) );
printf ( "lround (-3.8) = %ld\n", lround(-3.8) );
return 0;
}
Rounding using to-nearest rounding:
lround (2.3) = 2
lround (3.8) = 4
lround (-2.3) = -2
lround (-3.8) = -4
long long int
类型的值返回。#include <iostream>
#include <cmath>
int main ()
{
printf ( "llround (2.3) = %lld\n", llround(2.3) );
printf ( "llround (3.8) = %lld\n", llround(3.8) );
printf ( "llround (-2.3) = %lld\n", llround(-2.3) );
printf ( "llround (-3.8) = %lld\n", llround(-3.8) );
return 0;
}
Rounding using to-nearest rounding:
llround (2.3) = 2
llround (3.8) = 4
llround (-2.3) = -2
llround (-3.8) = -4
/* rint example */
#include <stdio.h> /* printf */
#include <fenv.h> /* fegetround, FE_* */
#include <math.h> /* rint */
int main ()
{
printf ("rounding using ");
switch (fegetround()) {
case FE_DOWNWARD: printf ("downward"); break;
case FE_TONEAREST: printf ("to-nearest"); break;
case FE_TOWARDZERO: printf ("toward-zero"); break;
case FE_UPWARD: printf ("upward"); break;
default: printf ("unknown");
}
printf (" rounding:\n");
printf ( "rint (2.3) = %.1f\n", rint(2.3) );
printf ( "rint (3.8) = %.1f\n", rint(3.8) );
printf ( "rint (-2.3) = %.1f\n", rint(-2.3) );
printf ( "rint (-3.8) = %.1f\n", rint(-3.8) );
return 0;
}
Rounding using to-nearest rounding:
rint (2.3) = 2.0
rint (3.8) = 4.0
rint (-2.3) = -2.0
rint (-3.8) = -4.0
long int
类型的值返回。/* lrint example */
#include <stdio.h> /* printf */
#include <fenv.h> /* fegetround, FE_* */
#include <math.h> /* lrint */
int main ()
{
printf ("rounding using ");
switch (fegetround()) {
case FE_DOWNWARD: printf ("downward"); break;
case FE_TONEAREST: printf ("to-nearest"); break;
case FE_TOWARDZERO: printf ("toward-zero"); break;
case FE_UPWARD: printf ("upward"); break;
default: printf ("unknown");
}
printf (" rounding:\n");
printf ( "lrint (2.3) = %ld\n", lrint(2.3) );
printf ( "lrint (3.8) = %ld\n", lrint(3.8) );
printf ( "lrint (-2.3) = %ld\n", lrint(-2.3) );
printf ( "lrint (-3.8) = %ld\n", lrint(-3.8) );
return 0;
}
Rounding using to-nearest rounding:
lrint (2.3) = 2
lrint (3.8) = 4
lrint (-2.3) = -2
lrint (-3.8) = -4
long long int
类型的值返回。/* llrint example */
#include <stdio.h> /* printf */
#include <fenv.h> /* fegetround, FE_* */
#include <math.h> /* llrint */
int main ()
{
printf ("rounding using ");
switch (fegetround()) {
case FE_DOWNWARD: printf ("downward"); break;
case FE_TONEAREST: printf ("to-nearest"); break;
case FE_TOWARDZERO: printf ("toward-zero"); break;
case FE_UPWARD: printf ("upward"); break;
default: printf ("unknown");
}
printf (" rounding:\n");
printf ( "llrint (2.3) = %lld\n", llrint(2.3) );
printf ( "llrint (3.8) = %lld\n", llrint(3.8) );
printf ( "llrint (-2.3) = %lld\n", llrint(-2.3) );
printf ( "llrint (-3.8) = %lld\n", llrint(-3.8) );
return 0;
}
Rounding using to-nearest rounding:
llrint (2.3) = 2
llrint (3.8) = 4
llrint (-2.3) = -2
llrint (-3.8) = -4
/* nearbyint example */
#include <stdio.h> /* printf */
#include <fenv.h> /* fegetround, FE_* */
#include <math.h> /* nearbyint */
int main ()
{
printf ("rounding using ");
switch (fegetround()) {
case FE_DOWNWARD: printf ("downward"); break;
case FE_TONEAREST: printf ("to-nearest"); break;
case FE_TOWARDZERO: printf ("toward-zero"); break;
case FE_UPWARD: printf ("upward"); break;
default: printf ("unknown");
}
printf (" rounding:\n");
printf ( "nearbyint (2.3) = %.1f\n", nearbyint(2.3) );
printf ( "nearbyint (3.8) = %.1f\n", nearbyint(3.8) );
printf ( "nearbyint (-2.3) = %.1f\n", nearbyint(-2.3) );
printf ( "nearbyint (-3.8) = %.1f\n", nearbyint(-3.8) );
return 0;
}
Rounding using to-nearest rounding:
nearbyint (2.3) = 2.0
nearbyint (3.8) = 4.0
nearbyint (-2.3) = -2.0
nearbyint (-3.8) = -4.0
#include <iostream>
#include <cmath>
int main()
{
printf("remainder of 5.3 / 2 is %f\n", remainder(5.3, 2));
printf("remainder of 18.5 / 4.2 is %f\n", remainder(18.5, 4.2));
return 0;
}
remainder of 5.3 / 2 is -0.700000
remainder of 18.5 / 4.2 is 1.700000
#include <iostream>
#include <cmath>
int main ()
{
double numer = 10.3;
double denom = 4.5;
int quot;
double result = remquo (numer,denom,");
printf ("numerator: %f\n", numer);
printf ("denominator: %f\n", denom);
printf ("remainder: %f\n", result);
printf ("quotient: %d\n", quot);
return 0;
}
numerator: 10.300000
denominator: 4.500000
remainder: 1.300000
quotient: 2
#include <iostream>
#include <cmath>
int main()
{
printf("copysign ( 10.0,-1.0) = %f\n", copysign(10.0, -1.0));
printf("copysign (-10.0,-1.0) = %f\n", copysign(-10.0, -1.0));
printf("copysign (-10.0, 1.0) = %f\n", copysign(-10.0, 1.0));
return 0;
}
copysign ( 10.0,-1.0) = -10.0
copysign (-10.0,-1.0) = -10.0
copysign (-10.0, 1.0) = 10.0
nan():返回double类型的静态NaN(非数字)值。NaN值用于标识浮点元素的未定义或不可表示的值,如负数的平方根或0/0的结果。库实现可以使用该参数以特定于实现的方式区分不同的NaN值。类似地,nanf和nanl分别返回float和long double类型的NaN值。
nextafter(x,y):返回x之后y方向的下一个可表示值。
#include <iostream>
#include <cmath>
int main()
{
printf("first representable value greater than zero: %e\n", nextafter(0.0, 1.0));
printf("first representable value less than zero: %e\n", nextafter(0.0, -1.0));
return 0;
}
first representable value greater than zero: 4.940656e-324
first representable value less than zero: -4.940656e-324
#include <iostream>
#include <cmath>
int main ()
{
printf ("first representable value greater than zero: %e\n", nexttoward(0.0,1.0L));
printf ("first representable value less than zero: %e\n", nexttoward(0.0,-1.0L));
return 0;
}
first representable value greater than zero: 4.940656e-324
first representable value less than zero: -4.940656e-324
#include <iostream>
#include <cmath>
int main ()
{
printf ("fdim (2.0, 1.0) = %f\n", fdim(2.0,1.0));
printf ("fdim (1.0, 2.0) = %f\n", fdim(1.0,2.0));
printf ("fdim (-2.0, -1.0) = %f\n", fdim(-2.0,-1.0));
printf ("fdim (-1.0, -2.0) = %f\n", fdim(-1.0,-2.0));
return 0;
}
fdim (2.0, 1.0) = 1.000000
fdim (1.0, 2.0) = 0.000000
fdim (-2.0,-1.0) = 0.000000
fdim (-1.0,-2.0) = 1.000000
#include <iostream>
#include <cmath>
int main ()
{
printf ("fmax (100.0, 1.0) = %f\n", fmax(100.0,1.0));
printf ("fmax (-100.0, 1.0) = %f\n", fmax(-100.0,1.0));
printf ("fmax (-100.0, -1.0) = %f\n", fmax(-100.0,-1.0));
return 0;
}
fmax (100.0, 1.0) = 100.000000
fmax (-100.0, 1.0) = 1.000000
fmax (-100.0,-1.0) = -1.000000
#include <iostream>
#include <cmath>
int main ()
{
printf ("fmin (100.0, 1.0) = %f\n", fmin(100.0,1.0));
printf ("fmin (-100.0, 1.0) = %f\n", fmin(-100.0,1.0));
printf ("fmin (-100.0, -1.0) = %f\n", fmin(-100.0,-1.0));
return 0;
}
fmin (100.0, 1.0) = 1.000000
fmin (-100.0, 1.0) = -100.000000
fmin (-100.0,-1.0) = -100.000000
#include <iostream>
#include <cmath>
int main ()
{
printf ("The absolute value of 3.1416 is %f\n", fabs (3.1416) );
printf ("The absolute value of -10.6 is %f\n", fabs (-10.6) );
return 0;
}
The absolute value of 3.1416 is 3.141600
The absolute value of -10.6 is 10.600000
#include <iostream>
#include <cmath>
int main ()
{
std::cout << "abs (3.1416) = " << std::abs (3.1416) << '\n';
std::cout << "abs (-10.6) = " << std::abs (-10.6) << '\n';
return 0;
}
abs (3.1416) = 3.1416
abs (-10.6) = 10.6
#include <iostream>
#include <cmath>
int main ()
{
double x,y,z,result;
x = 10.0, y = 20.0, z = 30.0;
#ifdef FP_FAST_FMA
result = fma(x,y,z);
#else
result = x*y+z;
#endif
printf ("10.0 * 20.0 + 30.0 = %f\n", result);
return 0;
}
10.0 * 20.0 + 30.0 = 230.000000
请注意,每个值只属于一个类别:零不是正常值。
#include <iostream>
#include <cmath>
int main()
{
double d = 1.0 / 0.0;
switch (fpclassify(d)) {
case FP_INFINITE: printf("infinite"); break;
case FP_NAN: printf("NaN"); break;
case FP_ZERO: printf("zero"); break;
case FP_SUBNORMAL: printf("subnormal"); break;
case FP_NORMAL: printf("normal"); break;
}
if (signbit(d)) printf(" negative\n");
else printf(" positive or unsigned\n");
return 0;
}
infinite positive or unsigned
#include <iostream>
#include <cmath>
int main()
{
printf ("isfinite(0.0) : %d\n",isfinite(0.0));
printf ("isfinite(1.0/0.0) : %d\n",isfinite(1.0/0.0));
printf ("isfinite(-1.0/0.0) : %d\n",isfinite(-1.0/0.0));
printf ("isfinite(sqrt(-1.0)): %d\n",isfinite(sqrt(-1.0)));
return 0;
}
isfinite(0.0) : 1
isfinite(1.0/0.0) : 0
isfinite(-1.0/0.0) : 0
isfinite(sqrt(-1.0)): 0
#include <iostream>
#include <cmath>
int main()
{
printf ("isinf(0.0) : %d\n",isinf(0.0));
printf ("isinf(1.0/0.0) : %d\n",isinf(1.0/0.0));
printf ("isinf(-1.0/0.0) : %d\n",isinf(-1.0/0.0));
printf ("isinf(sqrt(-1.0)): %d\n",isinf(sqrt(-1.0)));
return 0;
}
isinf(0.0) : 0
isinf(1.0/0.0) : 1
isinf(-1.0/0.0) : 1
isinf(sqrt(-1.0): 0
#include <iostream>
#include <cmath>
int main()
{
printf("isnan(sqrt(-1.0)): %d\n", isnan(sqrt(-1.0)));
return 0;
}
isnan(sqrt(-1.0)): 1
#include <iostream>
#include <cmath>
int main()
{
printf("isnormal(1.0) : %d\n", isnormal(1.0));
return 0;
}
isnormal(1.0) : 1
#include <iostream>
#include <cmath>
int main()
{
printf("signbit(0.0) : %d\n", signbit(0.0));
printf("signbit(sqrt(-1.0)): %d\n", signbit(sqrt(-1.0)));
return 0;
}
signbit(0.0) : 0
signbit(sqrt(-1.0)): 1
#include <iostream>
#include <cmath>
int main()
{
double result;
result = log(10.0);
if (isgreater(result, 0.0))
printf("log(10.0) is positive");
else
printf("log(10.0) is not positive");
return 0;
}
log(10.0) is positive
#include <iostream>
#include <cmath>
int main ()
{
double result;
result = log (10.0);
if (isgreaterequal(result,0.0))
printf ("log(10.0) is not negative");
else
printf ("log(10.0) is negative");
return 0;
}
log(10.0) is not negative
#include <iostream>
#include <cmath>
int main ()
{
double result;
result = log (10.0);
if (isless(result,0.0))
printf ("log(10.0) is negative");
else
printf ("log(10.0) is not negative");
return 0;
}
log(10.0) is not negative
#include <iostream>
#include <cmath>
int main ()
{
double result;
result = log (10.0);
if (islessequal(result,0.0))
printf ("log(10.0) is not positive");
else
printf ("log(10.0) is positive");
return 0;
}
log(10.0) is positive
#include <iostream>
#include <cmath>
int main ()
{
double result;
result = log (10.0);
if (islessgreater(result,0.0))
printf ("log(10.0) is not zero");
else
printf ("log(10.0) is zero");
return 0;
}
log(10.0) is not zero
#include <iostream>
#include <cmath>
int main ()
{
double result;
result = sqrt (-1.0);
if (isunordered(result,0.0))
printf ("sqrt(-1.0) and 0.0 cannot be ordered");
else
printf ("sqrt(-1.0) and 0.0 can be ordered");
return 0;
}
sqrt(-1.0) and 0.0 cannot be ordered
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。