pmccabe2html: escaping of special characters
[gnulib.git] / lib / printf-frexp.c
index 0c95a61..1a7b0c4 100644 (file)
@@ -1,21 +1,22 @@
 /* Split a double into fraction and mantissa, for hexadecimal printf.
-   Copyright (C) 2007 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc.
 
-   This program is free software; you can redistribute it and/or modify
+   This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2, or (at your option)
-   any later version.
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
 
-   You should have received a copy of the GNU General Public License along
-   with this program; if not, write to the Free Software Foundation,
-   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include <config.h>
+#if ! defined USE_LONG_DOUBLE
+# include <config.h>
+#endif
 
 /* Specification.  */
 #ifdef USE_LONG_DOUBLE
@@ -63,7 +64,7 @@
 #endif
 
 DOUBLE
-FUNC (DOUBLE x, int *exp)
+FUNC (DOUBLE x, int *expptr)
 {
   int exponent;
   DECL_ROUNDING
@@ -93,76 +94,76 @@ FUNC (DOUBLE x, int *exp)
     exponent = 0;
     if (x >= L_(1.0))
       {
-       /* A nonnegative exponent.  */
-       {
-         DOUBLE pow2_i; /* = pow2[i] */
-         DOUBLE powh_i; /* = powh[i] */
-
-         /* Invariants: pow2_i = 2^2^i, powh_i = 2^-2^i,
-            x * 2^exponent = argument, x >= 1.0.  */
-         for (i = 0, pow2_i = L_(2.0), powh_i = L_(0.5);
-              ;
-              i++, pow2_i = pow2_i * pow2_i, powh_i = powh_i * powh_i)
-           {
-             if (x >= pow2_i)
-               {
-                 exponent += (1 << i);
-                 x *= powh_i;
-               }
-             else
-               break;
-
-             pow2[i] = pow2_i;
-             powh[i] = powh_i;
-           }
-       }
-       /* Here 1.0 <= x < 2^2^i.  */
+        /* A nonnegative exponent.  */
+        {
+          DOUBLE pow2_i; /* = pow2[i] */
+          DOUBLE powh_i; /* = powh[i] */
+
+          /* Invariants: pow2_i = 2^2^i, powh_i = 2^-2^i,
+             x * 2^exponent = argument, x >= 1.0.  */
+          for (i = 0, pow2_i = L_(2.0), powh_i = L_(0.5);
+               ;
+               i++, pow2_i = pow2_i * pow2_i, powh_i = powh_i * powh_i)
+            {
+              if (x >= pow2_i)
+                {
+                  exponent += (1 << i);
+                  x *= powh_i;
+                }
+              else
+                break;
+
+              pow2[i] = pow2_i;
+              powh[i] = powh_i;
+            }
+        }
+        /* Here 1.0 <= x < 2^2^i.  */
       }
     else
       {
-       /* A negative exponent.  */
-       {
-         DOUBLE pow2_i; /* = pow2[i] */
-         DOUBLE powh_i; /* = powh[i] */
-
-         /* Invariants: pow2_i = 2^2^i, powh_i = 2^-2^i,
-            x * 2^exponent = argument, x < 1.0, exponent >= MIN_EXP - 1.  */
-         for (i = 0, pow2_i = L_(2.0), powh_i = L_(0.5);
-              ;
-              i++, pow2_i = pow2_i * pow2_i, powh_i = powh_i * powh_i)
-           {
-             if (exponent - (1 << i) < MIN_EXP - 1)
-               break;
-
-             exponent -= (1 << i);
-             x *= pow2_i;
-             if (x >= L_(1.0))
-               break;
-
-             pow2[i] = pow2_i;
-             powh[i] = powh_i;
-           }
-       }
-       /* Here either x < 1.0 and exponent - 2^i < MIN_EXP - 1 <= exponent,
-          or 1.0 <= x < 2^2^i and exponent >= MIN_EXP - 1.  */
-
-       if (x < L_(1.0))
-         /* Invariants: x * 2^exponent = argument, x < 1.0 and
-            exponent - 2^i < MIN_EXP - 1 <= exponent.  */
-         while (i > 0)
-           {
-             i--;
-             if (exponent - (1 << i) >= MIN_EXP - 1)
-               {
-                 exponent -= (1 << i);
-                 x *= pow2[i];
-                 if (x >= L_(1.0))
-                   break;
-               }
-           }
-
-       /* Here either x < 1.0 and exponent = MIN_EXP - 1,
-          or 1.0 <= x < 2^2^i and exponent >= MIN_EXP - 1.  */
+        /* A negative exponent.  */
+        {
+          DOUBLE pow2_i; /* = pow2[i] */
+          DOUBLE powh_i; /* = powh[i] */
+
+          /* Invariants: pow2_i = 2^2^i, powh_i = 2^-2^i,
+             x * 2^exponent = argument, x < 1.0, exponent >= MIN_EXP - 1.  */
+          for (i = 0, pow2_i = L_(2.0), powh_i = L_(0.5);
+               ;
+               i++, pow2_i = pow2_i * pow2_i, powh_i = powh_i * powh_i)
+            {
+              if (exponent - (1 << i) < MIN_EXP - 1)
+                break;
+
+              exponent -= (1 << i);
+              x *= pow2_i;
+              if (x >= L_(1.0))
+                break;
+
+              pow2[i] = pow2_i;
+              powh[i] = powh_i;
+            }
+        }
+        /* Here either x < 1.0 and exponent - 2^i < MIN_EXP - 1 <= exponent,
+           or 1.0 <= x < 2^2^i and exponent >= MIN_EXP - 1.  */
+
+        if (x < L_(1.0))
+          /* Invariants: x * 2^exponent = argument, x < 1.0 and
+             exponent - 2^i < MIN_EXP - 1 <= exponent.  */
+          while (i > 0)
+            {
+              i--;
+              if (exponent - (1 << i) >= MIN_EXP - 1)
+                {
+                  exponent -= (1 << i);
+                  x *= pow2[i];
+                  if (x >= L_(1.0))
+                    break;
+                }
+            }
+
+        /* Here either x < 1.0 and exponent = MIN_EXP - 1,
+           or 1.0 <= x < 2^2^i and exponent >= MIN_EXP - 1.  */
       }
 
     /* Invariants: x * 2^exponent = argument, and
@@ -170,12 +171,12 @@ FUNC (DOUBLE x, int *exp)
        or 1.0 <= x < 2^2^i and exponent >= MIN_EXP - 1.  */
     while (i > 0)
       {
-       i--;
-       if (x >= pow2[i])
-         {
-           exponent += (1 << i);
-           x *= powh[i];
-         }
+        i--;
+        if (x >= pow2[i])
+          {
+            exponent += (1 << i);
+            x *= powh[i];
+          }
       }
     /* Here either x < 1.0 and exponent = MIN_EXP - 1,
        or 1.0 <= x < 2.0 and exponent >= MIN_EXP - 1.  */
@@ -184,6 +185,6 @@ FUNC (DOUBLE x, int *exp)
 
   END_ROUNDING ();
 
-  *exp = exponent;
+  *expptr = exponent;
   return x;
 }