Mercurial > hg > octave-lyh
diff liboctave/lo-mappers.cc @ 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 | 99c410f7f0b0 |
children | 39930366b709 |
line wrap: on
line diff
--- 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 }