This code is wrong but it tells what I am trying to do
float a[2] = {1.0f, 2.0f};
EM_ASM({
var sum = $0[0] + $0[1];
}, a);
What would be the correct way?
This code is wrong but it tells what I am trying to do
float a[2] = {1.0f, 2.0f};
EM_ASM({
var sum = $0[0] + $0[1];
}, a);
What would be the correct way?
The correct way would be
float a[2] = {1.0f, 2.0f};
EM_ASM_({
var sum = getValue($0+0, 'float') + getValue($0+4, 'float');
}, a);
To get the n
element in the float array do this getValue($0 + n*4, 'float')
If it was a double array it would be getValue($0 + n*8, 'double')