home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #4 / amigaacscoverdisc1998-041998.iso / utilities / shareware / dev / vbcc / machines / amiga68k / libsrc / math / math_ieee / frexp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-12-30  |  302 b   |  27 lines

  1. #include <math.h>
  2.  
  3. double frexp(double x,int *p)
  4. {
  5.   int neg,j;
  6.   j=neg=0;
  7.  
  8.   if(x<0){
  9.       x=-x;
  10.       neg=1;
  11.   }
  12.   if(x>=1){
  13.     while(x>=1){
  14.         j++;
  15.         x/=2;
  16.       }
  17.   }else if(x<0.5&&x!=0){
  18.     while(x<0.5){
  19.         j--;
  20.         x*=2;
  21.       }
  22.   }
  23.   *p = j;
  24.   if(neg) x=-x;
  25.   return x;
  26. }
  27.