Closed Bug 1113718 Opened 5 years ago Closed 5 years ago

Uint8ClampedArray constructor rounds wrong

Categories

(Core :: JavaScript: Standard Library, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla38
Tracking Status
firefox38 --- fixed

People

(Reporter: evilpie, Assigned: evilpie)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

new Uint8ClampedArray([2.6])
>> [2]
x = new Uint8ClampedArray([0])
x[0] = 2.6
x
>> [3]
Memo to self: need to check whether this affects SharedUint8ClampedArray too.
Tom, note that the bug here is really the opposite of what you reported.  ToUint8Clamp is supposed to round, not to truncate: http://people.mozilla.org/~jorendorff/es6-draft.html#sec-touint8clamp.

Ergo it's the conversion from the array-element (the first case in your test) that is buggy, not the conversion of assignment (the second case).

(SharedTypedArray does not allow the construction from array literal, and the assignment case behaves correctly.  Removing dependency.)
No longer blocks: shared-array-buffer
Sorry Lars, but I think you might be confused somehow. Like I said "Uint8ClampedArray constructor rounds wrong", which is the first case.
(In reply to Tom Schuster [:evilpie] from comment #3)
> Sorry Lars, but I think you might be confused somehow. Like I said
> "Uint8ClampedArray constructor rounds wrong", which is the first case.

Indeed I misinterpreted the Summary.
Attached patch new-clampedSplinter Review
Assignee: nobody → evilpies
Status: NEW → ASSIGNED
Attachment #8560436 - Flags: review?(lhansen)
Attachment #8560436 - Flags: review?(lhansen) → review+
https://hg.mozilla.org/mozilla-central/rev/9a45db9e1e28
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla38
You need to log in before you can comment on or make changes to this bug.