Question

I've this raw data:

var x = [25];
var y = [0.004011332988739014, 0.0027810593601316214, 0.0015301937237381935, 0.0009717916836962104];

And I want to put them into this ArrayBuffer:

var buff = new ArrayBuffer(24);
var f64s = new Float64Array(h, 0, 1);
var f32s = new Float32Array(h, 1 * 4);

I can fill data into Float32Array with this method:

f32s.set(y)

How do I set value of array x into Float64Array with methods similar to above. So I can get something like this:

new ArrayBuffer([25, 0.004011332988739014, 0.0027810593601316214, 0.0015301937237381935, 0.0009717916836962104]);

Thank you,

Was it helpful?

Solution

var f64s = new Float64Array(x.length + y.length);
f64s.set(x, 0);
f64s.set(y, x.length);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top