w_sqrtf.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* vi: set sw=4 ts=4: */
  2. /* sqrtf for uClibc
  3. *
  4. * Copyright (C) 2002 by Erik Andersen <andersen@uclibc.org>
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU Library General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or (at your
  9. * option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful, but WITHOUT
  12. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
  14. * for more details.
  15. *
  16. * You should have received a copy of the GNU Library General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. */
  20. /*
  21. * wrapper for sqrt(x)
  22. */
  23. #include "math.h"
  24. #include "math_private.h"
  25. #ifdef __STDC__
  26. float sqrtf(float x) /* wrapper sqrt */
  27. #else
  28. float sqrtf(x) /* wrapper sqrt */
  29. float x;
  30. #endif
  31. {
  32. #ifdef _IEEE_LIBM
  33. return __ieee754_sqrt(x);
  34. #else
  35. float z;
  36. z = __ieee754_sqrt(x);
  37. if(_LIB_VERSION == _IEEE_ || isnan(x)) return z;
  38. if(x<0.0) {
  39. return __kernel_standard(x,x,26); /* sqrt(negative) */
  40. } else
  41. return z;
  42. #endif
  43. }