binary to float

Dan Laüt's icon

On a Yamaha Motif sound module, general tuning can be adjusted from -102.4 to +102.3 cents. (The question why these values are not integers running from -99 to +99 is another matter.)

The value is represented by a 4-byte sequence, where only the low nibble of each byte is significant. The value of 0.0 is represented by the sequence 0x00 0x04 0x00 0x00.

In the course of developing a routine to convert the sequence to floating point and vice versa, I ran into the obstacle illustrated in the patch attached, which is that when converted to binary (or hex, as here) for the purpose of cobbling the bytes into an Fp, the output does not include the fractional part.

How does one get from -102.4 to 0xFFFFFFFFFFFFFF9A back to -102.4?

Max Patch
Copy patch and select New From Clipboard in Max.

Source Audio's icon
Max Patch
Copy patch and select New From Clipboard in Max.