sf_fabs.c 936 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* sf_fabs.c -- float version of s_fabs.c.
  2. * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
  3. */
  4. /*
  5. * ====================================================
  6. * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
  7. *
  8. * Developed at SunPro, a Sun Microsystems, Inc. business.
  9. * Permission to use, copy, modify, and distribute this
  10. * software is freely granted, provided that this notice
  11. * is preserved.
  12. * ====================================================
  13. */
  14. /*
  15. * fabsf(x) returns the absolute value of x.
  16. */
  17. #include "fdlibm.h"
  18. #ifdef __STDC__
  19. float fabsf(float x)
  20. #else
  21. float fabsf(x)
  22. float x;
  23. #endif
  24. {
  25. uint32_t ix;
  26. GET_FLOAT_WORD(ix,x);
  27. SET_FLOAT_WORD(x,ix&0x7fffffff);
  28. return x;
  29. }
  30. #ifdef _DOUBLE_IS_32BITS
  31. #ifdef __STDC__
  32. double fabs(double x)
  33. #else
  34. double fabs(x)
  35. double x;
  36. #endif
  37. {
  38. return (double) fabsf((float) x);
  39. }
  40. #endif /* defined(_DOUBLE_IS_32BITS) */