w_scalb.c 1.4 KB

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