Mercurial > hg > octave-terminal
changeset 9412:ddcc0da700b8
Fix 'format rat' for values like '1 - eps'
author | David Bateman <dbateman@free.fr> |
---|---|
date | Wed, 01 Jul 2009 08:37:24 +0200 |
parents | c9636d98e5cd |
children | 5cd879a0d8c4 |
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.)