Mercurial > hg > octave-kai
changeset 7522:8a6965a01176
log2: ensure F strictly less than 1
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sun, 24 Feb 2008 03:32:49 -0500 |
parents | 6f10bbb2854a |
children | f2000f1971ab |
files | doc/interpreter/contributors.in scripts/ChangeLog scripts/specfun/log2.m |
diffstat | 3 files changed, 13 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/interpreter/contributors.in +++ b/doc/interpreter/contributors.in @@ -59,10 +59,11 @@ Peter Gustafson Kai Habel William P. Y. Hadisoeseno +Jaroslav Hajek Benjamin Hall Kim Hansen Soren Hauberg -Jaroslav Hajek +Dave Hawthorne Daniel Heiserer Yozo Hida Roman Hodek
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,8 @@ +2008-02-24 John W. Eaton <jwe@octave.org> + + * specfun/log2.m: Ensure returned value of F strictly less than 1. + From Dave Hawthorne <davehawthorne@ieee.org>. + 2008-02-22 Ben Abbott <bpabbott@mac.com> * specfun/legendre.m: Doc fix.
--- a/scripts/specfun/log2.m +++ b/scripts/specfun/log2.m @@ -53,6 +53,12 @@ f = abs (x) + (x == 0); e = (floor (log (f) / log (2)) + 1) .* (x != 0); f = sign (x) .* f ./ (2 .^ e); + ## Workaround to cases of f == 1 (due to precision issues). + idx = abs (f) >= 1; + if (any (idx)) + f(idx) /= 2; + e(idx)++; + endif else error ("log2 takes at most 2 output arguments"); endif