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.
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/3f1d3d4f-bcdc-452f-8e04-c286cfd44d89%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.