Closed
Bug 1115067
Opened 11 years ago
Closed 11 years ago
Rounding error using Uint8ClampedArray
Categories
(Firefox :: Untriaged, defect)
Tracking
()
RESOLVED
INVALID
People
(Reporter: github, Unassigned)
Details
User Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:35.0) Gecko/20100101 Firefox/35.0
Build ID: 20141218174327
Steps to reproduce:
Setting an value with decimal x.5 in an Uint8ClampedArray rounds in the wrong direction:
var ca = new Uint8ClampedArray(1);
ca[0] = 100.5;
Actual results:
console.log(ca[0]); // => 100, should be 101
ca[0] = 100.51; // min. trigger value: 100.50000000000001
console.log(ca[0]); // => 101, correct
See http://jsfiddle.net/epistemex/7bak3dLd/
Expected results:
It should round any decimal value equal to x.5 or higher up to next integer value.
The rounding process seem to be checking decimals like "> .5" instead of ">= .5".
(or < .5).
I see that in the ES6 draft, if the touint8clamp function is used here, it's suppose to use even tie instead of rounding up IIUC. This would be mathematically incorrect in any instance imo, and I cannot see the logic reasoning for using this approach here?
Status: UNCONFIRMED → RESOLVED
Closed: 11 years ago
Resolution: --- → INVALID
You need to log in
before you can comment on or make changes to this bug.
Description
•