Skip to content

Commit

Permalink
Fix modulo operation for longlong operands.
Browse files Browse the repository at this point in the history
Modulo is a weird operator, and there are actually two different
macros: one for Byte and Unsigned, and one for all other datatypes.
The code that decides between the two was missing the "Q"
identifier for longlong datatypes, so it was returning garbage.

Added one test to check for this.
  • Loading branch information
d-lamb committed Feb 16, 2015
1 parent 0762095 commit 389f1fd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Basic/Ops/ops.pd
Expand Up @@ -163,7 +163,7 @@ EOH
types(BU) %{
\$c() = BU_$func(\$a(),\$b());
%}
types(SLNFD) %{
types(SLNQFD) %{
\$c() = $func(\$a(),\$b());
%}
ENDCODE
Expand Down
6 changes: 3 additions & 3 deletions t/ops.t
Expand Up @@ -15,7 +15,7 @@ sub tapprox {
return $d < 0.01;
}

print "1..43\n";
print "1..44\n";

# $a0 = zeroes 3,5;
# $b0 = xvals $a0;
Expand Down Expand Up @@ -143,7 +143,7 @@ ok(38, all $data == 1);
ok(39, all $data eq $data); # check eq operator


# check proper modulus...
# check proper modulus... really we should do this for each datatype
$a = xvals(15)-7;
$b = $a % 3;
ok(40,sum($b != pdl(2,0,1,2,0,1,2,0,1,2,0,1,2,0,1)) == 0);
Expand All @@ -155,4 +155,4 @@ ok(42,sum($b != 0) == 0);
$b = $a->qsorti;
$c = $b % 3;
ok(43,all($c->double==pdl("0 1 2 " x 5)));

ok(44,longlong(10)%longlong(5)==0);

0 comments on commit 389f1fd

Please sign in to comment.