Modulo now behaves exactly like Scratch 1.4 and passes http://scratch.mit.edu/projects/13839488/
This commit is contained in:
Nathan Dinsmore 2013-12-19 15:11:02 -05:00
parent 0539393688
commit 489a212fee

View file

@ -30,7 +30,7 @@ Primitives.prototype.addPrimsTo = function(primTable) {
primTable['-'] = function(b) { return interp.numarg(b, 0) - interp.numarg(b, 1); };
primTable['*'] = function(b) { return interp.numarg(b, 0) * interp.numarg(b, 1); };
primTable['/'] = function(b) { return interp.numarg(b, 0) / interp.numarg(b, 1); };
primTable['%'] = function(b) { return interp.numarg(b, 0) % interp.numarg(b, 1); };
primTable['%'] = this.primModulo;
primTable['randomFrom:to:'] = this.primRandom;
primTable['<'] = function(b) { return (interp.numarg(b, 0) < interp.numarg(b, 1)); };
primTable['='] = function(b) { return (interp.arg(b, 0) == interp.arg(b, 1)); };
@ -78,9 +78,9 @@ Primitives.prototype.primLetterOf = function(b) {
}
Primitives.prototype.primModulo = function(b) {
var modulus = interp.numarg(b, 1);
var n = interp.numarg(b, 0) % modulus;
if (n < 0) n += modulus;
var dividend = interp.numarg(b, 1);
var n = interp.numarg(b, 0) % dividend;
if (n / dividend < 0) n += dividend;
return n;
}