sign.c 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #if defined(__ppc__)
  2. /*******************************************************************************
  3. * *
  4. * File sign.c, *
  5. * Functions copysign and __signbitd. *
  6. * For PowerPC based machines. *
  7. * *
  8. * Copyright © 1991, 2001 Apple Computer, Inc. All rights reserved. *
  9. * *
  10. * Written by Ali Sazegari, started on June 1991. *
  11. * *
  12. * August 26 1991: no CFront Version 1.1d17 warnings. *
  13. * September 06 1991: passes the test suite with invalid raised on *
  14. * signaling nans. sane rom code behaves the same. *
  15. * September 24 1992: took the Ò#include support.hÓ out. *
  16. * Dcember 02 1992: PowerPC port. *
  17. * July 20 1994: __fabs added *
  18. * July 21 1994: deleted unnecessary functions: neg, COPYSIGNnew, *
  19. * and SIGNNUMnew. *
  20. * April 11 2001: first port to os x using gcc. *
  21. * removed fabs and deffered to gcc for direct *
  22. * instruction generation. *
  23. * *
  24. *******************************************************************************/
  25. #include "fp_private.h"
  26. /*******************************************************************************
  27. * *
  28. * Function copysign. *
  29. * Implementation of copysign for the PowerPC. *
  30. * *
  31. ********************************************************************************
  32. * Note: The order of the operands in this function is reversed from that *
  33. * suggested in the IEEE standard 754. *
  34. *******************************************************************************/
  35. double copysign ( double arg2, double arg1 )
  36. {
  37. union
  38. {
  39. dHexParts hex;
  40. double dbl;
  41. } x, y;
  42. /*******************************************************************************
  43. * No need to flush NaNs out. *
  44. *******************************************************************************/
  45. x.dbl = arg1;
  46. y.dbl = arg2;
  47. y.hex.high = y.hex.high & 0x7FFFFFFF;
  48. y.hex.high = ( y.hex.high | ( x.hex.high & dSgnMask ) );
  49. return y.dbl;
  50. }
  51. #endif /* __ppc__ */