copysign
输出:
nan
nextafter
nexttoward
返回由x的绝对值和y的符号组成的值。
/* copysign example */
#include <stdio.h> /* printf */
#include <math.h> /* copysign */
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
:
NaN
(Not-A-Number) 不是一个数字,double类型。
返回x到y方向上的x的下一个元素。
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));
first representable value greater than zero: 4.940656e-324 // 比0大一点的数 first representable value less than zero: -4.940656e-324 // 比0小一点的数
和nextafter相似,只是比它更精确
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));
first representable value greater than zero: 4.940656e-324
first representable value less than zero: -4.940656e-324