Mercurial > hg > octave-kai > gnulib-hg
changeset 8229:e27c94a6558a
Fix a bug with 1.0.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sat, 24 Feb 2007 16:31:38 +0000 |
parents | 93084dc35013 |
children | fc7bcbeadfee |
files | ChangeLog lib/frexpl.c |
diffstat | 2 files changed, 12 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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,
--- a/lib/frexpl.c +++ b/lib/frexpl.c @@ -30,11 +30,14 @@ 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. */ - if (x != x || x + x == x ) + if (x != x || x + x == x) { *exp = 0; return x; @@ -44,7 +47,7 @@ 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; @@ -90,6 +93,7 @@ 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);