# HG changeset patch # User John W. Eaton # Date 1403903097 14400 # Node ID 23e511f3395d858f7f9d63624d642d28b573004c # Parent 39844e6ccf131983e342dfd019b7a1854e9fc5cd# Parent 23681c9ea7baeaec05e889e39f8c77ea94139030 maint: Periodic merge of stable to gui-release. diff -r 39844e6ccf13 -r 23e511f3395d libinterp/corefcn/data.cc --- a/libinterp/corefcn/data.cc Fri Jun 27 17:04:16 2014 -0400 +++ b/libinterp/corefcn/data.cc Fri Jun 27 17:04:57 2014 -0400 @@ -722,6 +722,8 @@ %!error rem ([1, 2], [3, 4, 5]) %!error rem (i, 1) +# bug 42627 +%!assert (rem (0.94, 0.01), 0.0); */ DEFALIAS (fmod, rem) @@ -873,6 +875,9 @@ ## non-integer real numbers %!assert (mod (2.1, 0.1), 0) %!assert (mod (2.1, 0.2), 0.1, eps) + +# bug 42627 +%!assert (mod (0.94, 0.01), 0.0); */ // FIXME: Need to convert reduction functions of this file for single precision diff -r 39844e6ccf13 -r 23e511f3395d liboctave/numeric/lo-mappers.h --- a/liboctave/numeric/lo-mappers.h Fri Jun 27 17:04:16 2014 -0400 +++ b/liboctave/numeric/lo-mappers.h Fri Jun 27 17:04:57 2014 -0400 @@ -321,33 +321,19 @@ { T q = x / y; - T n = xfloor (q); - - if (X_NINT (y) != y) + if (X_NINT (y) != y + && (std::abs ((q - X_NINT (q)) / X_NINT (q)) + < std::numeric_limits::epsilon ())) + retval = 0; + else { - if (X_NINT (q) == q) - n = q; - else - { - if (x >= -1 && x <= 1) - { - if (std::abs (q - X_NINT (q)) - < std::numeric_limits::epsilon ()) - n = X_NINT (q); - } - else - { - if (std::abs ((q - X_NINT (q))/ X_NINT (q)) - < std::numeric_limits::epsilon ()) - n = X_NINT (q); - } - } + T n = xfloor (q); + + // Prevent use of extra precision. + volatile T tmp = y * n; + + retval = x - tmp; } - - // Prevent use of extra precision. - volatile T tmp = y * n; - - retval = x - tmp; } if (x != y && y != 0 && retval != 0) @@ -368,33 +354,19 @@ { T q = x / y; - T n = xtrunc (q); - - if (X_NINT (y) != y) + if (X_NINT (y) != y + && (std::abs ((q - X_NINT (q)) / X_NINT (q)) + < std::numeric_limits::epsilon ())) + retval = 0; + else { - if (X_NINT (q) == q) - n = q; - else - { - if (x >= -1 && x <= 1) - { - if (std::abs (q - X_NINT (q)) - < std::numeric_limits::epsilon ()) - n = X_NINT (q); - } - else - { - if (std::abs ((q - X_NINT (q))/ X_NINT (q)) - < std::numeric_limits::epsilon ()) - n = X_NINT (q); - } - } + T n = xtrunc (q); + + // Prevent use of extra precision. + volatile T tmp = y * n; + + retval = x - tmp; } - - // Prevent use of extra precision. - volatile T tmp = y * n; - - retval = x - tmp; } if (x != y && y != 0 && retval != 0)