# Convert decimal to float

**URL:** <https://forum.inductiveautomation.com/t/convert-decimal-to-float/80901>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [October 24, 2023, 12:50pm UTC](https://forum.inductiveautomation.com/t/convert-decimal-to-float/80901 "2023-10-24T12:50:00Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [March 20, 2025, 8:29am UTC](https://forum.inductiveautomation.com/t/convert-decimal-to-float/80901/10 "2025-03-20T08:29:29Z")

</div>

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

In the script library:

```python
from java.lang import Float

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

```

expression:

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

```

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/9/e9b44cd24ce38c4ea5547bcf1747eebacb5d45c8.png)

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.

---

_[View the full topic](https://forum.inductiveautomation.com/t/convert-decimal-to-float/80901)._
