Convert decimal to float

You could probably handle that by making SIM_AI an expression tag, using the other 2 in its expression.

In the script library:

from java.lang import Float

def convert_to_float(int_val):
	return Float.intBitsToFloat(int_val)

expression:

runScript(
	'test.convert_to_float', 0,
	{[.]sources/source}[0] << 16 | {[.]sources/source}[1]
)

image

I think it's cleaner/easier to follow, as it makes SIM_AI responsible for computing its value, and I'm willing to bet it's also faster.

edit: Wait, it seems the tag doesn't update when the source values change. I'm thinking it's because they're in an array...
edit2: nevermind, it did change, but the formatting on the final tag was hiding it.

1 Like