Claude Pache (2013-09-16T11:40:44.000Z)
domenic at domenicdenicola.com (2013-09-25T02:45:54.608Z)
Le 16 sept. 2013 à 11:30, raul mihaila <raul.mihaila at gmail.com> a écrit : > I think the definition of modulo is wrong. http://people.mozilla.org/~jorendorff/es6-draft.html#sec-5.2 > k should be of the same sign as x not as y. I think the definition is correct, and is more useful than the opposite convention. It is indeed the opposite convention of the one used by the remainder operator (`%` in JS), but it is not the remainder operator. (BTW, is there any chance that the modulo operator [1] will be introduced in EcmaScript, rather sooner than later?) [1] http://wiki.ecmascript.org/doku.php?id=strawman:modulo_operator In fact, since `x modulo y` is apparently only use with positive (and integral) `y` in the specification, the definition should be simplified, by restricting to the case where `y` is positive. > Also, shouldn't ToUint32 and ToUint16 return only positive numbers? If the argument is, for example, -3, the result will be -3 (assuming that the modulo definition is wrong). Or maybe the argument will never be negative? Assuming the modulo definition is correct, `ToUint32` and `ToUint16` work as expected (if the argument is `-3` the result is `2^32-3`, resp. `2^16-3`.