s_copysign.c 873 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /* @(#)s_copysign.c 1.3 95/01/18 */
  2. /*
  3. * ====================================================
  4. * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
  5. *
  6. * Developed at SunSoft, a Sun Microsystems, Inc. business.
  7. * Permission to use, copy, modify, and distribute this
  8. * software is freely granted, provided that this notice
  9. * is preserved.
  10. * ====================================================
  11. */
  12. /*
  13. * copysign(double x, double y)
  14. * copysign(x,y) returns a value with the magnitude of x and
  15. * with the sign bit of y.
  16. */
  17. #include "fdlibm.h"
  18. #ifndef _DOUBLE_IS_32BITS
  19. #ifdef __STDC__
  20. double copysign(double x, double y)
  21. #else
  22. double copysign(x,y)
  23. double x,y;
  24. #endif
  25. {
  26. uint32_t hx, hy;
  27. GET_HIGH_WORD(hx, x);
  28. GET_HIGH_WORD(hy, y);
  29. SET_HIGH_WORD(x, (hx&0x7fffffff)|(hy&0x80000000));
  30. return x;
  31. }
  32. #endif /* _DOUBLE_IS_32BITS */