s_fabs.c 729 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /* @(#)s_fabs.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. * fabs(x) returns the absolute value of x.
  14. */
  15. #include "fdlibm.h"
  16. #ifndef _DOUBLE_IS_32BITS
  17. #ifdef __STDC__
  18. double fabs(double x)
  19. #else
  20. double fabs(x)
  21. double x;
  22. #endif
  23. {
  24. uint32_t hx;
  25. GET_HIGH_WORD(hx,x);
  26. SET_HIGH_WORD(x, hx & 0x7fffffff);
  27. return x;
  28. }
  29. #endif /* _DOUBLE_IS_32BITS */