home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 Mobile / Chip_Mobile_2001.iso / palm / hobby / palmoon / palmoon.EXE / e_scalb.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-16  |  1.5 KB  |  58 lines

  1. // 15 August 1997, Rick Huebner:  Small changes made to adapt for MathLib
  2.  
  3. /* @(#)e_scalb.c 5.1 93/09/24 */
  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. #if defined(LIBM_SCCS) && !defined(lint)
  16. static char rcsid[] = "$NetBSD: e_scalb.c,v 1.6 1995/05/10 20:46:09 jtc Exp $";
  17. #endif
  18.  
  19. /*
  20.  * __ieee754_scalb(x, fn) is provide for
  21.  * passing various standard test suite. One 
  22.  * should use scalbn() instead.
  23.  */
  24.  
  25. #include "math.h"
  26. #include "math_private.h"
  27.  
  28. #ifdef _SCALB_INT
  29. #ifdef __STDC__
  30.     double __ieee754_scalb(double x, int fn)
  31. #else
  32.     double __ieee754_scalb(x,fn)
  33.     double x; int fn;
  34. #endif
  35. #else
  36. #ifdef __STDC__
  37.     double __ieee754_scalb(double x, double fn)
  38. #else
  39.     double __ieee754_scalb(x,fn)
  40.     double x, fn;
  41. #endif
  42. #endif
  43. {
  44. #ifdef _SCALB_INT
  45.     return __scalbn(x,fn);
  46. #else
  47.     if (__isnan(x)||__isnan(fn)) return x*fn;
  48.     if (!__finite(fn)) {
  49.         if(fn>0.0) return x*fn;
  50.         else       return x/(-fn);
  51.     }
  52.     if (__rint(fn)!=fn) return (fn-fn)/(fn-fn);
  53.     if ( fn > 65000.0) return jumpto__scalbn(x, 65000);
  54.     if (-fn > 65000.0) return jumpto__scalbn(x,-65000);
  55.     return jumpto__scalbn(x,(int)fn);
  56. #endif
  57. }
  58.