Function: copysign

copysign is a function defined in floatfns.c.

Signature

(copysign X1 X2)

Documentation

Copy sign of X2 to value of X1, and return the result.

Cause an error if X1 or X2 is not a float.

View in manual

Probably introduced at or before Emacs version 24.1.

Source Code

// Defined in /usr/src/emacs/src/floatfns.c
{
  double f1, f2;

  CHECK_FLOAT (x1);
  CHECK_FLOAT (x2);

  f1 = XFLOAT_DATA (x1);
  f2 = XFLOAT_DATA (x2);

  /* Use signbit instead of copysign, to avoid calling make_float when
     the result is X1.  */
  return signbit (f1) != signbit (f2) ? make_float (-f1) : x1;
}