diff liboctave/util/oct-inttypes.h @ 25858:1f52a96c8c21 stable

Fix mod operation for signed integer types (bug #54602). * oct-inttypes.h (): * data.cc (Fmod): Add BIST tests for bug #54602.
author Gene Harvey <gharveymn@gmail.com>
date Fri, 07 Sep 2018 09:33:33 -0700
parents 144820478378
children fb775d5a626a
line wrap: on
line diff
--- a/liboctave/util/oct-inttypes.h	Fri Sep 07 15:30:02 2018 +0200
+++ b/liboctave/util/oct-inttypes.h	Fri Sep 07 09:33:33 2018 -0700
@@ -663,7 +663,7 @@
     if (y != 0)
       {
         T r = x % y;
-        return ((r < 0) != (y < 0)) ? r + y : r;
+        return (r == 0) ? 0 : (((r < 0) != (y < 0)) ? r + y : r);
       }
     else
       return x;