函数原型: double _copysign( double x, double y );
所属库: float.h(属于C标准库)
函数功能: 以第二个参数y的符号(正或负)返回第一个参数x
相关函数: _chgsign
#include <stdio.h>
#include <float.h>
int main( void )
{
double x, y;
x = y = 0.0;
scanf("%lf%lf", &x, &y);
printf("x: %f\y: %f\Result: %f\", x, y, _copysign( x, y ) );
return 0;
}
输入:
1.2 -1.2
输出:
x: 1.200000
y: -1.200000
Result: -1.200000
Press any key to continue