s_copysign.c 751 B

1234567891011121314151617181920212223242526272829
  1. /*
  2. * ====================================================
  3. * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
  4. *
  5. * Developed at SunPro, a Sun Microsystems, Inc. business.
  6. * Permission to use, copy, modify, and distribute this
  7. * software is freely granted, provided that this notice
  8. * is preserved.
  9. * ====================================================
  10. */
  11. /*
  12. * copysign(double x, double y)
  13. * copysign(x,y) returns a value with the magnitude of x and
  14. * with the sign bit of y.
  15. */
  16. #include "math.h"
  17. #include "math_private.h"
  18. double copysign(double x, double y)
  19. {
  20. u_int32_t hx,hy;
  21. GET_HIGH_WORD(hx,x);
  22. GET_HIGH_WORD(hy,y);
  23. SET_HIGH_WORD(x,(hx&0x7fffffff)|(hy&0x80000000));
  24. return x;
  25. }
  26. libm_hidden_def(copysign)