document LOG_LPR facility
[unix-history] / usr / src / lib / libc / gen / frexp.c
index 49831ad..a02be48 100644 (file)
@@ -1,12 +1,16 @@
-/* @(#)frexp.c 4.1 (Berkeley) %G% */
+#ifndef lint
+static char sccsid[] = "@(#)frexp.c    5.1 (Berkeley) %G%";
+#endif not lint
+
 /*
 /*
-       the call
-               x = frexp(arg,&exp);
-       must return a double fp quantity x which is <1.0
-       and the corresponding binary exponent "exp".
-       such that
-               arg = x*2^exp
-*/
+ *     the call
+ *             x = frexp(arg,&exp);
+ *     must return a double fp quantity x which is <1.0
+ *     and the corresponding binary exponent "exp".
+ *     such that
+ *             arg = x*2^exp
+ *     if the argument is 0.0, return 0.0 mantissa and 0 exponent.
+ */
 
 double
 frexp(x,i)
 
 double
 frexp(x,i)
@@ -21,12 +25,12 @@ int *i;
                x = -x;
                neg = 1;
                }
                x = -x;
                neg = 1;
                }
-       if(x>1.0)
-               while(x>1){
+       if(x>=1.0)
+               while(x>=1.0){
                        j = j+1;
                        x = x/2;
                        }
                        j = j+1;
                        x = x/2;
                        }
-       else if(x<0.5)
+       else if(x<0.5 && x != 0.0)
                while(x<0.5){
                        j = j-1;
                        x = 2*x;
                while(x<0.5){
                        j = j-1;
                        x = 2*x;