Chapter Contents

Previous

Next
copysign

copysign



Propagate the sign of a floating-point number to another

Portability: C99


SYNOPSIS
DESCRIPTION
RETURN VALUE
RELATED FUNCTIONS
SEE ALSO


SYNOPSIS

   #include <math.h>

   double copysign(double x, double y);
   float copysignf(float x, float y);
   long double copysignl(long double x, long double y);


DESCRIPTION

The copysign function generates a floating-point result with the magnitude of the first argument and the sign of the second argument. In other words, it propagates the sign bit of the second argument to the first.

The function name copysignf should be used for float arguments, and copysignl for long double arguments. Alternately, if the header file tgmath.h is included, copysign may be used with any numeric argument type.


RETURN VALUE

The value of the first argument, with the sign of the second.


RELATED FUNCTIONS

signbit


SEE ALSO

"Mathematical Functions" in Chapter 2, "Function Categories"


Chapter Contents

Previous

Next

Top of Page

Copyright © 2004 by SAS Institute Inc., Cary, NC, USA. All rights reserved.