copysignf Function

Returns the value of x but with the sign of y.

Include

<math.h>

Prototype

float copysignf(float x, float y);

Arguments

x
a single precision floating-point value
y
value whose sign will apply to the result

Return Value

Returns the value of x but with the sign of y.

Example

#include <math.h>
#include <stdio.h>

int main(void)
{
  float x,y,z;

  x = 10.0;
  y = -3.0;
  z = copysignf(x, y);
  printf("The value %f but with %f's sign is %f\n\n", x, y, z);
}

Example Output

The value 10.000000 but with -3.000000's sign is -10.000000