# HG changeset patch # User John W. Eaton # Date 1207762302 14400 # Node ID 63e048203ed310a3e18d386585cc875a11762138 # Parent 8b77c3a5d87a3eb807afd10130ac0b5fac93b255 changeset: 7800:9828eda04f24 tag: tip user: Michael Goffioul 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). diff --git a/liboctave/ChangeLog b/liboctave/ChangeLog --- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,5 +1,8 @@ 2008-04-09 Michael Goffioul + * 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 __WIN32__ platforms. diff --git a/liboctave/lo-mappers.cc b/liboctave/lo-mappers.cc --- 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 }