Uint8ClampedArray rounding behaviour?
Qantas 94 Heavy
qantas94heavy at gmail.com
Sat Apr 5 18:44:15 PDT 2014
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
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss