# 2.11BSD#431 - /usr/src/lib/libc/gen/frexp.c

##### Functions

    frexp             X

       1: #if defined(LIBC_SCCS) && !defined(lint)
       2: static char sccsid[] = "@(#)frexp.c	5.2 (Berkeley) 3/9/86";
       3: #endif LIBC_SCCS and not lint
       4:
       5: /*
       6:  *	the call
       7:  *		x = frexp(arg,&exp);
       8:  *	must return a double fp quantity x which is <1.0
       9:  *	and the corresponding binary exponent "exp".
      10:  *	such that
      11:  *		arg = x*2^exp
      12:  *	if the argument is 0.0, return 0.0 mantissa and 0 exponent.
      13:  */
      14:
      15: double
      16: frexp(x,i)
      17: double x;
      18: int *i;
      19: {
      20:     int neg;
      21:     int j;
      22:     j = 0;
      23:     neg = 0;
      24:     if(x<0){
      25:         x = -x;
      26:         neg = 1;
      27:         }
      28:     if(x>=1.0)
      29:         while(x>=1.0){
      30:             j = j+1;
      31:             x = x/2;
      32:             }
      33:     else if(x<0.5 && x != 0.0)
      34:         while(x<0.5){
      35:             j = j-1;
      36:             x = 2*x;
      37:             }
      38:     *i = j;
      39:     if(neg) x = -x;
      40:     return(x);
      41:     }

#### Defined functions

frexp defined in line 15; never used

#### Defined variables

sccsid defined in line 2; never used

Last modified: 1986-03-10 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 324 |