Mercurial > hg > octave-nkf
diff liboctave/numeric/lo-mappers.h @ 20584:0cefba1a1030
Make mod() and rem() Matlab compatible for corner cases (bug #45587).
* data.cc(Frem): Update docstring. Update and add BIST tests.
* data.cc(Fmod): Update docstring. Update and add BIST tests.
* lo-mappers.h: Add #include lo-ieee.h to get octave_NaN definition.
* lo-mappers.h(xrem): Return NaN if second input is 0. Always use signbit of
first input argument to decide sign of output.
* lo-mappers.h(xmod): Always use signbit of second input argument to decide
sign of output.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 22 Jul 2015 09:46:42 -0700 |
parents | 4197fc428c7d |
children |
line wrap: on
line diff
--- a/liboctave/numeric/lo-mappers.h +++ b/liboctave/numeric/lo-mappers.h @@ -28,6 +28,7 @@ #include "oct-cmplx.h" #include "lo-math.h" +#include "lo-ieee.h" // Double Precision extern OCTAVE_API double xtrunc (double x); @@ -334,7 +335,7 @@ } } - if (x != y && y != 0 && retval != 0) + if (x != y && y != 0) retval = xcopysign (retval, y); return retval; @@ -347,7 +348,7 @@ T retval; if (y == 0) - retval = x; + retval = octave_NaN; else { T q = x / y; @@ -367,7 +368,7 @@ } } - if (x != y && y != 0 && retval != 0) + if (x != y && y != 0) retval = xcopysign (retval, x); return retval;