The input is a buffer containing single precision float numbers (32 bits, little endian).
What I want to produce is a JSON string containing those numbers, preserving the exact same values without precision change.
The problem is: as soon as the value is stored in a JS number, it is converted to 64bits, introducing precision changes.
For example:
const buffer = Buffer.from("cdcccc3d", "hex"); // cdcccc3d is 0.1 in 32 bits float LE
console.log(buffer.readFloatLE(0)); // 0.10000000149011612 => bad
How to get this value as a string preserving the original precision with no conversion? Here: "0.1".
Bonus point if I manage to produce a JSON string containing the number with original precision: { "value": 0.1 }.