Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
  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.  
  14. #if defined(LIBM_SCCS) && !defined(lint)
  15. static char rcsid[] = "$Id: w_scalb.c,v 1.4 1994/08/10 20:35:37 jtc Exp $";
  16. #endif
  17.  
  18. /*
  19.  * wrapper scalb(double x, double fn) is provide for
  20.  * passing various standard test suite. One
  21.  * should use scalbn() instead.
  22.  */
  23.  
  24. #include "math.h"
  25. #include "math_private.h"
  26.  
  27. #include <errno.h>
  28.  
  29. #ifdef __STDC__
  30. #ifdef _SCALB_INT
  31.         double scalb(double x, int fn)          /* wrapper scalb */
  32. #else
  33.         double scalb(double x, double fn)       /* wrapper scalb */
  34. #endif
  35. #else
  36.         double scalb(x,fn)                      /* wrapper scalb */
  37. #ifdef _SCALB_INT
  38.         double x; int fn;
  39. #else
  40.         double x,fn;
  41. #endif
  42. #endif
  43. {
  44. #ifdef _IEEE_LIBM
  45.         return __ieee754_scalb(x,fn);
  46. #else
  47.         double z;
  48.         z = __ieee754_scalb(x,fn);
  49.         if(_LIB_VERSION == _IEEE_) return z;
  50.         if(!(finite(z)||isnan(z))&&finite(x)) {
  51.             return __kernel_standard(x,(double)fn,32); /* scalb overflow */
  52.         }
  53.         if(z==0.0&&z!=x) {
  54.             return __kernel_standard(x,(double)fn,33); /* scalb underflow */
  55.         }
  56. #ifndef _SCALB_INT
  57.         if(!finite(fn)) errno = ERANGE;
  58. #endif
  59.         return z;
  60. #endif
  61. }
  62.