Waldemar Horwat (2013-07-25T19:11:46.000Z)
On Thu, Jul 25, 2013 at 12:00 PM, Brendan Eich <brendan at mozilla.com> wrote:

> Michael Haufe wrote:
>
>> In 2008 I first proposed the addition of an integer division operator to
>> the language. At the time Brendan noted his regret for this oversight and
>> desire for the operator as well. I am not seeing this operator available in
>> the current draft. Can/will this be rectified?
>>
>> a div b = (a - a % b) / b
>>
>
> This turns out to be equivalent to
>
>  (a/b)|0
>
>
> which is how asm.js optimizes to avoid the FPU already.
>

It's not equivalent for values greater than 2^31. The | version wraps
around; div would give the correct answer.

    Waldemar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130725/176dc867/attachment.html>
domenic at domenicdenicola.com (2013-07-25T19:58:04.233Z)
It's not equivalent for values greater than 2^31. The `|` version wraps
around; `div` would give the correct answer.
domenic at domenicdenicola.com (2013-07-25T19:55:28.852Z)
On Thu, Jul 25, 2013 at 12:00 PM, Brendan Eich <brendan at mozilla.com> wrote:

> This turns out to be equivalent to
>
> ```js
>  (a/b)|0
> ```
>
> which is how asm.js optimizes to avoid the FPU already.

It's not equivalent for values greater than 2^31. The `|` version wraps
around; `div` would give the correct answer.