Uint8ClampedArray rounding behaviour?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Uint8ClampedArray rounding behaviour?

Qantas 94 Heavy
Currently, the ES6 spec uses ToUint8Clamp to convert the set value into a number in a Uint8ClampedArray. From what I read of the spec, ToUint8Clamp rounds ties away from zero (rev 22, 7.1.11):

> 6. Let f be floor(number).
> 7. If f+0.5 ≤ number, then return f+1.

However, in the WebIDL spec (4.2.5, step 3), it's specified to round to the nearest even integer:

> 1. Round x to the nearest integer, choosing the even integer if it lies halfway between two.
> 2. Set x to min(max(x, 0), 2^8 − 1).
> 3. Return the IDL octet value that represents the same numeric value as x.

Currently, both Firefox and Chrome round ties to even, not away from zero. Am I reading this completely wrong, or is there a discrepancy in the behaviour between the ES6 version and what's currently implemented in browsers?

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Uint8ClampedArray rounding behaviour?

Boris Zbarsky
On 4/5/14 9:44 PM, Qantas 94 Heavy wrote:
> Am I reading this completely wrong, or is there a discrepancy in
> the behaviour between the ES6 version and what's currently implemented
> in browsers?

You're reading correctly.  The ES6 version is wrong and should be fixed.

-Boris

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Uint8ClampedArray rounding behaviour?

Allen Wirfs-Brock
In reply to this post by Qantas 94 Heavy
Bug report? What's the the correct behavior?

Boris Zbarsky <[hidden email]> wrote:

>On 4/5/14 9:44 PM, Qantas 94 Heavy wrote:
>> Am I reading this completely wrong, or is there a discrepancy in
>> the behaviour between the ES6 version and what's currently implemented
>> in browsers?
>
>You're reading correctly.  The ES6 version is wrong and should be fixed.
>
>-Boris
>
>_______________________________________________
>es-discuss mailing list
>[hidden email]
>https://mail.mozilla.org/listinfo/es-discuss
>
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Uint8ClampedArray rounding behaviour?

Allen Wirfs-Brock
In reply to this post by Qantas 94 Heavy
Err oops, sorry I missed the top post

Allen Wirfs-Brock <[hidden email]> wrote:

>Bug report? What's the the correct behavior?
>
>Boris Zbarsky <[hidden email]> wrote:
>
>>On 4/5/14 9:44 PM, Qantas 94 Heavy wrote:
>>> Am I reading this completely wrong, or is there a discrepancy in
>>> the behaviour between the ES6 version and what's currently implemented
>>> in browsers?
>>
>>You're reading correctly.  The ES6 version is wrong and should be fixed.
>>
>>-Boris
>>
>>_______________________________________________
>>es-discuss mailing list
>>[hidden email]
>>https://mail.mozilla.org/listinfo/es-discuss
>>
>_______________________________________________
>es-discuss mailing list
>[hidden email]
>https://mail.mozilla.org/listinfo/es-discuss
>
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss