I tried using TypedArray
var arr_data = new Float32Array(300);
arr_data[i] = parseFloat(s); // this is in a for loop where I read each value from csv as string
since my numbers are in decimals.
However, when I try to store the float value in the above array, it doesn't get stored as it is.
For example: 1180.952381 from the .csv is stored as 1180.95239257812
I tried using Float64Array and it gave a better result however not the exact value
1180.952381 is stored as 1180.95238100000
and 1175.824176 is stored as 1175.82417599999
I believe using Float32Array would be better considering memory usage, however not sure why the values aren't getting stored in the original form
© Espruino, powered by microcosm.
Report a problem