comparison libinterp/corefcn/data.cc @ 18903:23681c9ea7ba stable

better guess if rem or mod could be zero (bug #42627) * lo-mappers.h (xmod, xrem): Don't treat abs(x)<=1 specially. Return 0 if x/y is assumed an integer. * data.cc: New tests for rem and mod.
author Olaf Till <i7tiol@t-online.de>
date Fri, 27 Jun 2014 11:49:22 +0200
parents 9d185537e5d1
children 23e511f3395d 2304ddfd736f
comparison
equal deleted inserted replaced
18897:c457a84bc7d3 18903:23681c9ea7ba
720 %!error rem () 720 %!error rem ()
721 %!error rem (1, 2, 3) 721 %!error rem (1, 2, 3)
722 %!error rem ([1, 2], [3, 4, 5]) 722 %!error rem ([1, 2], [3, 4, 5])
723 %!error rem (i, 1) 723 %!error rem (i, 1)
724 724
725 # bug 42627
726 %!assert (rem (0.94, 0.01), 0.0);
725 */ 727 */
726 728
727 DEFALIAS (fmod, rem) 729 DEFALIAS (fmod, rem)
728 730
729 DEFUN (mod, args, , 731 DEFUN (mod, args, ,
871 %!assert (mod (uint8 ([1:5]), 4), uint8 ([1,2,3,0,1])) 873 %!assert (mod (uint8 ([1:5]), 4), uint8 ([1,2,3,0,1]))
872 874
873 ## non-integer real numbers 875 ## non-integer real numbers
874 %!assert (mod (2.1, 0.1), 0) 876 %!assert (mod (2.1, 0.1), 0)
875 %!assert (mod (2.1, 0.2), 0.1, eps) 877 %!assert (mod (2.1, 0.2), 0.1, eps)
878
879 # bug 42627
880 %!assert (mod (0.94, 0.01), 0.0);
876 */ 881 */
877 882
878 // FIXME: Need to convert reduction functions of this file for single precision 883 // FIXME: Need to convert reduction functions of this file for single precision
879 884
880 #define NATIVE_REDUCTION_1(FCN, TYPE, DIM) \ 885 #define NATIVE_REDUCTION_1(FCN, TYPE, DIM) \