Re: [jslint] Re: JSLint rejects (n % 1)
- View SourceOn Thu, Apr 28, 2011 at 07:46, Martin <mbrrtt@...> wrote:
> Do you really think that 'n % 1' is 'clever code', while 'n -Yes. The meaning of 'n - Math.floor(n)' is obvious. The meaning of 'n % 1'
> Math.floor(n)' is not?
is not obvious, so much so that at least one person on this mailing list
> Sure, the operator '%' doesn't wear its meaning on its face. It's notThe problem isn't the meaning of '%'; I knew that % was remainder/modulo.
> standard mathematical notation; you have to look it up the first time you
> see it, in a book or in the spec. But did you know what 'x || y' or 'x ? y :
> z' meant the first time you saw them?
The problem is that extending modulo to floating point gives you at least
three different possible behaviors, as
http://en.wikipedia.org/wiki/Modulo_operation points out, and people's
expectations aren't necessarily met by those extended definitions.
[Non-text portions of this message have been removed]