copysignl Function

Returns a long double precision value with the magnitude of one value and the sign of another.




long double copysignl(long double x, long double y);


a double precision floating-point value
value whose sign will apply to the result

Return Value

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


See the notes at the beginning of this chapter or section for information on using printf() or scanf() (and other functions reading and writing the stdin or stdout streams) in the example code.

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

int main(void)
  long double x,y,z;

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

Example Output

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