C examples for math.h:copysign
function
<cmath> <ctgmath> <math.h>
Copy sign
long double copysignl (long double x, long double y); long double copysign (long double x, long double y); double copysign (double x , double y); double copysign (double x , double y); float copysignf (float x , float y); float copysign (float x , float y); double copysign (Type1 x , Type2 y);
Parameter | Description |
---|---|
x | Value with the magnitude of the resulting value. |
y | Value with the sign of the resulting value. |
The value with a magnitude of x and the sign of y.
#include <stdio.h> #include <math.h> /* copysign */ int main ()//from w ww.j a v a 2s . c om { printf ("%f\n", copysign( 10.0,-1.0)); printf ("%f\n", copysign(-10.0,-1.0)); printf ("%f\n", copysign(-10.0, 1.0)); return 0; }