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

  1. // 15 August 1997, Rick Huebner:  Small changes made to adapt for MathLib
  2.  
  3. /* @(#)s_logb.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: s_logb.c,v 1.8 1995/05/10 20:47:50 jtc Exp $";
  17. #endif
  18.  
  19. /*
  20.  * double logb(x)
  21.  * IEEE 754 logb. Included to pass IEEE test suite. Not recommend.
  22.  * Use ilogb instead.
  23.  */
  24.  
  25. #include "math.h"
  26. #include "math_private.h"
  27.  
  28. #ifdef __STDC__
  29.     double __logb(double x)
  30. #else
  31.     double __logb(x)
  32.     double x;
  33. #endif
  34. {
  35.     int32_t lx,ix;
  36.     EXTRACT_WORDS(ix,lx,x);
  37.     ix &= 0x7fffffff;            /* high |x| */
  38.     if((ix|lx)==0) return -1.0/jumpto__fabs(x);
  39.     if(ix>=0x7ff00000) return x*x;
  40.     if((ix>>=20)==0)             /* IEEE 754 logb */
  41.         return -1022.0;
  42.     else
  43.         return (double) (ix-1023);
  44. }
  45. weak_alias (__logb, logb)
  46. #ifdef NO_LONG_DOUBLE
  47. strong_alias (__logb, __logbl)
  48. weak_alias (__logb, logbl)
  49. #endif
  50.