You are here:
Print

In TML, the fractional numbers (usually stored in 32 bits fixed variables) are represented (in hex) using the “16.16” format.
According to this format, to get the hex value of a fractional number, the first step is to multiply the fractional number with 65536. The result will be rounded or truncated and cast to a 32 bits signed integer value, that can be converted to hexadecimal.

Examples:
+4.6 = 4.6 (FLOAT) * 65536 = 301465.6
The result can be rounded or truncated to an integer number.
Assuming that it was truncated to 301465 and cast to a 32 bits signed integer (INTEGER32), the hexadecimal value is: 0x00049999.

-3.3 IU = -3.3 (FLOAT) * 65536 = -216268.8
After the result is truncate to -216268 and cast to a 32 bits signed integer (INTEGER32), the resulted hex value is: 0xFFFCB334.

For more details regarding the Fixed Point Maths, please follow the link below.
– http://www.hugi.scene.org/online/coding/hugi%2015%20-%20cmtadfix.htm

Next The negative numbers representation in hex