Howard Martinez
2014-04-14
Looking at the communication between the client/server I am unsure how its packing the float data.
For example here is a message for rotating something to 15 degrees
b03800000000001cca02001000300000b41000000aaaaab0d0000000
The important part is the 0x0aaaaab0 which is the 4byte parameter for the rotation angle action or 0xb410. However that doesn't seem to make sense using:
http://babbage.cs.qc.cuny.edu/IEEE-754.old/Decimal.html
And inputting 15 degrees you get 0x41700000,
This site:
http://babbage.cs.qc.cuny.edu/IEEE-754/
Gives the same number of 0x41700000 so I am not sure where the 0x0AAAAAAB0 came from.. I have tried other angles like -15 or 1 or 45 or 90 and I can't seem to figure out how its packing them.
In the code it seems like its using this public void setFloatParameter(int widgetID, String paramID, float value)
But I can't find anything in that call tree that would explain it, or I am just not seeing it.
EDIT: Btw I tried degrees -> radians and that didn't seem to help either.
Howard Martinez
2014-04-15
Tried some more values, and its just not lining up there is obviously something I am missing here.
INPUT IEEE 754 661
-45 Degrees = 0xc2340000 = 0xE0000000
-15 Degrees = 0xc1700000 = 0xF5555550
-5 Degrees = 0xc0a00000 = 0xFC71C71C
0 Degrees = 0x00000000 = 0x00000000
5 Degrees = 0x40a00000 = 0x038E38E4
15 Degrees = 0x41700000 = 0x0AAAAAB0
45 Degrees = 0x42340000 = 0x20000000
13.2 Degrees = 0x41533333 = 0x0962FC90
Howard Martinez
2014-04-15
NVM I found it.. its a 2's complement packed fr(180) type int form of a float. That's strange but it works I guess.
Hervé Girod
2014-04-15
Sorry, I was away ;)
Yes, a lot of "float" parameters are in fact coded in fr(180) (for angles), fr(1) (for ratios with 1 as maximum value) or fr(32768) (for distance in m). There are still some real float values, such as for EditBoxNumeric values.
The reason work they did this was to have the maximum precision for values whose minimum and maximum are fixed, but I agree that having only float values in all cases would have been simpler ;)
Anonymous