Mercurial > hg > octave-max
comparison src/pr-output.cc @ 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 | 9681984e898d |
children | bd994ce20158 |
comparison
equal
deleted
inserted
replaced
12028:2de1ae881cea | 12029:ee264f77eaed |
---|---|
269 { | 269 { |
270 double flip = 1. / frac; | 270 double flip = 1. / frac; |
271 double step = xround (flip); | 271 double step = xround (flip); |
272 double nextn = n; | 272 double nextn = n; |
273 double nextd = d; | 273 double nextd = d; |
274 | |
275 // Have we converged to 1/intmax ? | |
276 if (m > 100 || fabs (frac) < 1 / static_cast<double>(INT_MAX)) | |
277 { | |
278 lastn = n; | |
279 lastd = d; | |
280 break; | |
281 } | |
282 | |
274 frac = flip - step; | 283 frac = flip - step; |
275 n = n * step + lastn; | 284 n = n * step + lastn; |
276 d = d * step + lastd; | 285 d = d * step + lastd; |
277 lastn = nextn; | 286 lastn = nextn; |
278 lastd = nextd; | 287 lastd = nextd; |
293 else if (buf.str().length() > static_cast<unsigned int>(len) && | 302 else if (buf.str().length() > static_cast<unsigned int>(len) && |
294 m > 1) | 303 m > 1) |
295 break; | 304 break; |
296 | 305 |
297 s = buf.str(); | 306 s = buf.str(); |
298 | |
299 // Have we converged to 1/intmax ? | |
300 if (m > 100 || fabs (frac) < 1 / static_cast<double>(INT_MAX)) | |
301 { | |
302 lastn = n; | |
303 lastd = d; | |
304 break; | |
305 } | |
306 } | 307 } |
307 | 308 |
308 if (lastd < 0.) | 309 if (lastd < 0.) |
309 { | 310 { |
310 // Move sign to the top | 311 // Move sign to the top |