# modulo

raul mihaila raul.mihaila at gmail.com
Sun Sep 22 03:29:58 PDT 2013

```I saw that. I'm sure the spec is clear enough for implementers. Somebody
mentioned that book authors should explain the spec to the developers. But
the books aren't enough. For example, I didn't see something like this in
any JS book that I've read. Array.apply(null, { length: 5
}).map(Number.call, Number);
When an empty array or an 'empty array-like object' (but with a valid
length property that is greater than 0) is used in the apply method, you'd
think that no arguments are actually passed, because it's not intuitive to
think otherwise. Only when you read the spec you see that something like
this is possible. (I'm not saying that there's absolutely no book that
explains this, but I can't read them all). I don't know what can be done...
Regarding the modulo/floor section, I would prefer something like this

The mathematical function floor(*x*) produces the largest integer (closest
to positive infinity) that is not larger than x.
The notation "*x* modulo *y*" (y must be finite and nonzero) computes a
value k of the same sign as y (or zero) such that abs(*k*) < abs(*y*) and *x
*-*k* = *q* × y, where q = floor(x / y).
NOTE floor(*x*) = *x*-(*x* modulo 1).

Raul M

On Sat, Sep 21, 2013 at 11:21 PM, Brendan Eich <brendan at mozilla.com> wrote:

> Since no one else replied, I will take a stab.
>
>> raul mihaila <mailto:raul.mihaila at gmail.com**>
>> September 17, 2013 2:46 PM
>>
>> If I understand correctly, q = floor(x / y), in x - k = q x y, where k =
>> x modulo y. If this is correct I think that such a note would be nice to
>> have for non-mathematicians. :)
>>
>
> It follows from 5.2, Algorithm Conventions, specifically:
>
> The mathematical function floor(x) yields the largest integer (closest to
> positive infinity) that is not larger than x.
>
> NOTE floor(x) = x-(x modulo 1).
>
> /be
>
>>
>> Raul M
>> ______________________________**_________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/**listinfo/es-discuss<https://mail.mozilla.org/listinfo/es-discuss>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130922/64792008/attachment.html>
```