Mercurial > hg > octave-nkf
changeset 12029:ee264f77eaed release-3-2-x
Fix 'format rat' for values like '1 - eps'
author | David Bateman <dbateman@free.fr> |
---|---|
date | Thu, 02 Jul 2009 06:31:29 +0200 |
parents | 2de1ae881cea |
children | 20a9a8180e33 |
files | src/ChangeLog src/pr-output.cc |
diffstat | 2 files changed, 15 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2008-07-01 David Bateman <dbateman@free.fr> + + * pr-output.cc (static inline std::string rational_approx (double, + int)): Test for underflow of fractional part of rational approximation + earlier in the loop. + 2009-07-01 Joe Rothweiler <octaveuser@sensicomm.com> * input.cc (raw_mode): Use TCSADRAIN if no wait.
--- a/src/pr-output.cc +++ b/src/pr-output.cc @@ -271,6 +271,15 @@ double step = xround (flip); double nextn = n; double nextd = d; + + // Have we converged to 1/intmax ? + if (m > 100 || fabs (frac) < 1 / static_cast<double>(INT_MAX)) + { + lastn = n; + lastd = d; + break; + } + frac = flip - step; n = n * step + lastn; d = d * step + lastd; @@ -295,14 +304,6 @@ break; s = buf.str(); - - // Have we converged to 1/intmax ? - if (m > 100 || fabs (frac) < 1 / static_cast<double>(INT_MAX)) - { - lastn = n; - lastd = d; - break; - } } if (lastd < 0.)