Could anyone help me with the following please?
How can I return a stream of bits which represents an array of double precision numbers?
For example, if I wanted to return two values each equal to 0.3333333333333 I could do the following in nodejs:
app.get('/GetBinaryData', function(req, res)
{
var buf = new Buffer(16);
buf[0] = 0x55;
buf[1] = 0x55;
buf[2] = 0x55;
buf[3] = 0x55;
buf[4] = 0x55;
buf[5] = 0x55;
buf[6] = 0xd5;
buf[7] = 0x3f;
buf[8] = 0x55;
buf[9] = 0x55;
buf[10] = 0x55;
buf[11] = 0x55;
buf[12] = 0x55;
buf[13] = 0x55;
buf[14] = 0xd5;
buf[15] = 0x3f;
res.send(buf);
}
);
At the client side I receive the stream and read 8 bits at a time to get the two values.
I understand there may be endian issues, but ignoring them the questions simplifies to:
If I want to send the content of this array:
var array = [7.1,5.2,13.3,300.4];
to a client from nodejs as binary data how can I do it?
(can be floats if necessary. Maybe there's a entirely better way I am unaware of, that would be great).
Thanks fro any help,
Mitch.