summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2016-06-07 00:23:13 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2016-06-07 00:23:13 +0000
commita0e724e6055d10541294e97632ba01db71e81a55 (patch)
tree2f3c8d159b0c513dd8c0f3c1b14381b643c12122
parent8d28bfa8394b1b96703ba2e29453ea7092ef7922 (diff)
downloadmpfr-a0e724e6055d10541294e97632ba01db71e81a55.tar.gz
[src/uceil_log2.c] Added a comment. Cosmetic changes.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@10446 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r--src/uceil_log2.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/uceil_log2.c b/src/uceil_log2.c
index 27aaca353..7ee5166ae 100644
--- a/src/uceil_log2.c
+++ b/src/uceil_log2.c
@@ -33,6 +33,8 @@ __gmpfr_ceil_log2 (double d)
union mpfr_ieee_double_extract x;
x.d = d;
+ /* The cast below is useless in theory, but let us not depend on the
+ integer promotion rules (for instance, tcc is currently wrong). */
exp = (long) x.s.exp - 1023;
x.s.exp = 1023; /* value for 1 <= d < 2 */
if (x.d != 1.0) /* d: not a power of two? */
@@ -42,19 +44,19 @@ __gmpfr_ceil_log2 (double d)
double m;
if (d < 0.0)
- return __gmpfr_floor_log2(-d)+1;
+ return __gmpfr_floor_log2 (-d) + 1;
else if (d == 0.0)
return -1023;
else if (d >= 1.0)
{
exp = 0;
- for( m= 1.0 ; m < d ; m *=2.0 )
+ for (m = 1.0; m < d; m *= 2.0)
exp++;
}
else
{
exp = 1;
- for( m= 1.0 ; m >= d ; m *= (1.0/2.0) )
+ for (m = 1.0; m >= d; m *= 0.5)
exp--;
}
#endif /* _MPFR_IEEE_FLOATS */