views:

286

answers:

1

I'm trying to replicate the Perl and PHP style pack and unpack functions in JavaScript.

Unsigned integers were easy enough, so my pack('n') and pack('N') are ok. But my lack of a computer science background is a hurdle now and I don't know where to start with pack('d') for packing JavaScript's standard floating point.

Is there a JavaScript library for this out there?

If not, is there a good resource where I can learn how to do this? I am fine with bitwise and binary level operations in JS, I just don't know where to start with the logic.

Thanks.

+2  A: 

Here is an existing solution: http://phpjs.org/functions/pack:880

Casey Hope
beautiful - thanks. I'll try that lib out!
Tim Whitlock