Mercurial > hg > octave-lojdl
changeset 7707:446dec9d1de5
changeset: 7800:9828eda04f24
tag: tip
user: Michael Goffioul <michael.goffioul@gmail.com>
date: Wed Apr 09 15:50:56 2008 +0200
files: liboctave/ChangeLog liboctave/lo-mappers.cc
description:
Fix xround implementation under Win32 (use gnulib version).
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 09 Apr 2008 13:31:12 -0400 |
parents | 30564b8b19f5 |
children | b42abee70a98 |
files | liboctave/ChangeLog liboctave/lo-mappers.cc |
diffstat | 2 files changed, 22 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,4 +1,7 @@ -2008-04-09 Michael Goffioul <michael.goffioul@gmail.com> +2008-04-09 Michael Goffioul <michael.goffioul@gmail.com> + + * lo-mappers.cc (xround): Avoid floating-point overflow when input + value is equal to bitmax implementation taken from gnulib). * file-stat.cc (file_stat::update_internal): Do not strip trailing file separator when path length is equal to 1 (handle case '\') under
--- a/liboctave/lo-mappers.cc +++ b/liboctave/lo-mappers.cc @@ -75,7 +75,24 @@ #if defined (HAVE_ROUND) return round (x); #else - return x > 0 ? floor (x + 0.5) : ceil (x - 0.5); + if (x >= 0) + { + double y = floor (x); + + if ((x - y) >= 0.5) + y += 1.0; + + return y; + } + else + { + double y = ceil (x); + + if ((y - x) >= 0.5) + y -= 1.0; + + return y; + } #endif }