0

I have an array of data (split from a buffer) Int16Array[326784] with values like [579, 578, 576, 574, 570, ...].

When I run b = new Int16Array(a.buffer, 0, a.length) the result is Int16Array[326784] but the values are different: [0, 0, ..., 0, 18756, 19779, 2, 0, 19541, 4, ...]

If I repeat the conversion: c = new Int16Array(b.buffer, 0, b.length) the result is same as b.

Why is the first conversion different?

2
  • You're doing it right. It needs more research. Commented Nov 16, 2016 at 2:12
  • 1
    I have solve this problem, and will update the answer later. Commented Nov 16, 2016 at 3:16

1 Answer 1

1

It caused by misunderstand TypedArray.

In the question, a = Int16Array(bufferA, x, y);, a is only a view of buffer, the a.buffer is bufferA.

So b = new Int16Array(a.buffer, 0, a.length) is equal b = new Int16Array(bufferA, 0, a.length)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.