summaryrefslogtreecommitdiff
path: root/lib/printf-frexp.c
diff options
context:
space:
mode:
authorAndreas Rottmann <a.rottmann@gmx.at>2010-05-27 18:23:15 +0200
committerAndreas Rottmann <a.rottmann@gmx.at>2010-05-27 18:23:15 +0200
commit3e0814cd9862b89c7a39672672937477bd87ddfb (patch)
tree159134a624e51509f40ed8823249f09a70d1dda3 /lib/printf-frexp.c
parent3bebb94360f1c2333feb8d504a9fa4f96984d8b7 (diff)
Imported Upstream version 0.9.3upstream/0.9.3
Diffstat (limited to 'lib/printf-frexp.c')
-rw-r--r--lib/printf-frexp.c148
1 files changed, 74 insertions, 74 deletions
diff --git a/lib/printf-frexp.c b/lib/printf-frexp.c
index 014c8539..cf6efdbc 100644
--- a/lib/printf-frexp.c
+++ b/lib/printf-frexp.c
@@ -1,5 +1,5 @@
/* Split a double into fraction and mantissa, for hexadecimal printf.
- Copyright (C) 2007 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@@ -92,76 +92,76 @@ FUNC (DOUBLE x, int *expptr)
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
@@ -169,12 +169,12 @@ FUNC (DOUBLE x, int *expptr)
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. */