w_scalb.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #if !defined(__ppc__)
  2. /* @(#)w_scalb.c 5.1 93/09/24 */
  3. /*
  4. * ====================================================
  5. * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
  6. *
  7. * Developed at SunPro, a Sun Microsystems, Inc. business.
  8. * Permission to use, copy, modify, and distribute this
  9. * software is freely granted, provided that this notice
  10. * is preserved.
  11. * ====================================================
  12. */
  13. #if defined(LIBM_SCCS) && !defined(lint)
  14. static char rcsid[] = "$NetBSD: w_scalb.c,v 1.6 1995/05/10 20:49:48 jtc Exp $";
  15. #endif
  16. /*
  17. * wrapper scalb(double x, double fn) is provide for
  18. * passing various standard test suite. One
  19. * should use scalbn() instead.
  20. */
  21. #include "math.h"
  22. #include "math_private.h"
  23. #include <errno.h>
  24. #ifdef __STDC__
  25. #ifdef _SCALB_INT
  26. double scalb(double x, int fn) /* wrapper scalb */
  27. #else
  28. double scalb(double x, double fn) /* wrapper scalb */
  29. #endif
  30. #else
  31. double scalb(x,fn) /* wrapper scalb */
  32. #ifdef _SCALB_INT
  33. double x; int fn;
  34. #else
  35. double x,fn;
  36. #endif
  37. #endif
  38. {
  39. #ifdef _IEEE_LIBM
  40. return __ieee754_scalb(x,fn);
  41. #else
  42. double z;
  43. z = __ieee754_scalb(x,fn);
  44. if(_LIB_VERSION == _IEEE_) return z;
  45. if(!(finite(z)||isnan(z))&&finite(x)) {
  46. return __kernel_standard(x,(double)fn,32); /* scalb overflow */
  47. }
  48. if(z==0.0&&z!=x) {
  49. return __kernel_standard(x,(double)fn,33); /* scalb underflow */
  50. }
  51. #ifndef _SCALB_INT
  52. if(!finite(fn)) errno = ERANGE;
  53. #endif
  54. return z;
  55. #endif
  56. }
  57. #endif /* !__ppc__ */