Hi,
I'm receiving some raw data from another application via TCP, and it's encoded as float64.
As an example:
>>>: 128 27 41 91 36 181 44 192
Is there a simple way to decode this?
Ta,
J
Decoding float64 stream
Hi,
I'm receiving some raw data from another application via TCP, and it's encoded as float64.
As an example:
>>>: 128 27 41 91 36 181 44 192
Is there a simple way to decode this?
Ta,
J
short answer: no
what do you mean decode? do you want to use the number in pd? if so, you need to make sure pure data can represent double precision numbers which means you need to be running pd-double. http://puredata.info/dev/pd-double. If not, then you have to convert it manually but I have no idea how things like rounding are done at the bit level, or even if it's possible to do when only being able to represent the lower of the two sizes. I would guess it is possible, read up on http://steve.hollasch.net/cgindex/coding/ieeefloat.html http://pages.cs.wisc.edu/~cs354-2/beyond354/reps.flpt.html http://en.wikipedia.org/wiki/Single-precision_floating-point_format http://en.wikipedia.org/wiki/IEEE_floating_point http://en.wikipedia.org/wiki/Double-precision_floating-point_format
pd does have bit manipulation objects though, which you can use for integers < 24 bits
you could maybe write an external to do this much easier (could be as simple as a few bit shifts, cast operations, and unions)
if you are running pd-double, it should work to take each byte of the mantissa into a (solely integer) float with bit-shifting and then divide/multiply the number appropriately
Thanks sebfumaster, I thought it wasn't going to be straightforward. Yes, by decode I mean convert into a number to use in pd.
I need to do some reading as I don't fully understand what I need to do but I'll start with those links.
Thanks
J
Oops! Looks like something went wrong!