Holiday notice: Cycling '74 will be closed Monday, October 9th. Manual authorization, support cases, and manual order processing will be delayed.

Nov 10 2013 | 9:13 pm

I'm writing a Max patch that receives via the serial object a stream of 32-bit floating point single precision numbers (from a 3D accelerometer/gyroscope device made by Yost Engineering, called the 3-Space Sensor). The incoming data comes in packets that look like this: 62 165 14 56, 62 142 208 54, etc. Each number in each group of 4 numbers is the decimal version of a hex number that represents one of the 4 bytes in the 32-bit float, so the first packet I just gave (62 165 14 56) is the same as 0x3E 0xA5 0x0E 0x38, which is actually the decimal number 0.322 written in the IEEE754 single precision 32-bit format. I've learned on Wikipedia that this format represents the fraction as the first 23 bits, the exponent as the next 8 bits, and the sign as the last bit.

Here's where I'm stuck. I can't figure out how to write a Max patch that will convert the incoming stream of 32-bit single precision packets into decimal numbers that I can work with (like connect to a dial object, etc.). I've found calculators online, but those don't help as I need the math behind those calculators.

Has anyone written a Max patch to convert single precision 32-bit floating point numbers into decimal numbers that I can send to a float object? If not can anyone send me the mathematical steps required to do this? Looking online at the math, I can't figure out what to do as you have to convert to binary then grab individual bits as stated above in order to figure out what the decimal number is. But I'm lost as to how this could be done in Max. Any help will be hugely appreciated! Thanks ahead of time.