projects
/
gnulib.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7200b30
)
Fix a bug with 1.0.
author
Bruno Haible
<bruno@clisp.org>
Sat, 24 Feb 2007 16:31:38 +0000
(16:31 +0000)
committer
Bruno Haible
<bruno@clisp.org>
Sat, 24 Feb 2007 16:31:38 +0000
(16:31 +0000)
ChangeLog
patch
|
blob
|
history
lib/frexpl.c
patch
|
blob
|
history
diff --git
a/ChangeLog
b/ChangeLog
index
ae7b937
..
1c3626c
100644
(file)
--- a/
ChangeLog
+++ b/
ChangeLog
@@
-1,3
+1,8
@@
+2007-02-24 Bruno Haible <bruno@clisp.org>
+
+ * lib/frexpl.c (frexpl): Correct return values for x = 1.0L. Don't
+ assume that an exponent fits in 20 bits.
+
2007-02-24 Jim Meyering <jim@meyering.net>
* m4/regex.m4: Update the description of the configure-time option,
2007-02-24 Jim Meyering <jim@meyering.net>
* m4/regex.m4: Update the description of the configure-time option,
diff --git
a/lib/frexpl.c
b/lib/frexpl.c
index
c563fc0
..
f78c400
100644
(file)
--- a/
lib/frexpl.c
+++ b/
lib/frexpl.c
@@
-30,11
+30,14
@@
long double
frexpl(long double x, int *exp)
{
long double
frexpl(long double x, int *exp)
{
- long double exponents[20], *next;
+ /* Since the exponent is an 'int', it fits in 64 bits. Therefore the
+ loops are executed no more than 64 times. */
+ long double exponents[64];
+ long double *next;
int exponent, bit;
/* Check for zero, nan and infinity. */
int exponent, bit;
/* Check for zero, nan and infinity. */
- if (x != x || x + x == x
)
+ if (x != x || x + x == x)
{
*exp = 0;
return x;
{
*exp = 0;
return x;
@@
-44,7
+47,7
@@
frexpl(long double x, int *exp)
return -frexpl(-x, exp);
exponent = 0;
return -frexpl(-x, exp);
exponent = 0;
- if (x > 1.0)
+ if (x >
=
1.0)
{
for (next = exponents, exponents[0] = 2.0L, bit = 1;
*next <= x + x;
{
for (next = exponents, exponents[0] = 2.0L, bit = 1;
*next <= x + x;
@@
-90,6
+93,7
@@
main (void)
x = frexpl(-1.0L / 0.0L, &y); printf ("%.6Lg %d\n", x, y);
x = frexpl(0.5L, &y); printf ("%.6Lg %d\n", x, y);
x = frexpl(0.75L, &y); printf ("%.6Lg %d\n", x, y);
x = frexpl(-1.0L / 0.0L, &y); printf ("%.6Lg %d\n", x, y);
x = frexpl(0.5L, &y); printf ("%.6Lg %d\n", x, y);
x = frexpl(0.75L, &y); printf ("%.6Lg %d\n", x, y);
+ x = frexpl(1.0L, &y); printf ("%.6Lg %d\n", x, y);
x = frexpl(3.6L, &y); printf ("%.6Lg %d\n", x, y);
x = frexpl(17.8L, &y); printf ("%.6Lg %d\n", x, y);
x = frexpl(8.0L, &y); printf ("%.6Lg %d\n", x, y);
x = frexpl(3.6L, &y); printf ("%.6Lg %d\n", x, y);
x = frexpl(17.8L, &y); printf ("%.6Lg %d\n", x, y);
x = frexpl(8.0L, &y); printf ("%.6Lg %d\n", x, y);