# Need to merge two INT values in order to make it float(real)

**URL:** <https://forum.inductiveautomation.com/t/need-to-merge-two-int-values-in-order-to-make-it-float-real/106452>\
**Category:** General Discussion\
**Tags:** ignition81\
**Created:** [May 20, 2025, 12:26pm UTC](https://forum.inductiveautomation.com/t/need-to-merge-two-int-values-in-order-to-make-it-float-real/106452 "2025-05-20T12:26:51Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![viral.patel](https://avatars.discourse-cdn.com/v4/letter/v/fbc32d/32.png) [@viral.patel](https://forum.inductiveautomation.com/u/viral.patel)\
**Post date:** [May 20, 2025, 12:26pm UTC](https://forum.inductiveautomation.com/t/need-to-merge-two-int-values-in-order-to-make-it-float-real/106452/1 "2025-05-20T12:26:51Z")

</div>

Hi...  
I have a ARRAY of integers, out of which two integers are showing value of one Float, how can i make it

---

<div class="post-metadata">

**Author:** ![Sahil\_Bendale](https://avatars.discourse-cdn.com/v4/letter/s/977dab/32.png) [@Sahil\_Bendale](https://forum.inductiveautomation.com/u/Sahil_Bendale)\
**Post date:** [May 20, 2025, 12:39pm UTC](https://forum.inductiveautomation.com/t/need-to-merge-two-int-values-in-order-to-make-it-float-real/106452/2 "2025-05-20T12:39:51Z")

</div>

Hi @viral.patel,  
Could you provide more context on what you are trying to do and what is happening? Like an example array?

Right now, I can think of possibilities that the array may have a typo where a ',' may have been typed out as '.' if the array is manually built. If another function is building this array, you can use int() to round it to an integer, and if you are getting 2 int values but in the form of a float for some reason, you can do a .split('.') to make them 2 separate values, but this will create a list, and you'll have to parse through it and .append() to your array.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 20, 2025, 12:42pm UTC](https://forum.inductiveautomation.com/t/need-to-merge-two-int-values-in-order-to-make-it-float-real/106452/3 "2025-05-20T12:42:07Z")

</div>

Combine your INTs to 32 bits using shift and bitwise OR, then run the result through Java's [Float.intBitsToFloat()](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Float.html#intBitsToFloat(int)) static method. Some inspiration:

> [@Convert decimal to float](https://forum.inductiveautomation.com/t/convert-decimal-to-float/80901/10):
>
> 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 …

---

<div class="post-metadata">

**Author:** ![Leor\_Fishman](https://avatars.discourse-cdn.com/v4/letter/l/e19adc/32.png) [@Leor\_Fishman](https://forum.inductiveautomation.com/u/Leor_Fishman)\
**Post date:** [May 20, 2025, 1:37pm UTC](https://forum.inductiveautomation.com/t/need-to-merge-two-int-values-in-order-to-make-it-float-real/106452/4 "2025-05-20T13:37:23Z")

</div>

i think this assumes that the ints are reliably split along the mantissa/decimal point?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [May 20, 2025, 1:39pm UTC](https://forum.inductiveautomation.com/t/need-to-merge-two-int-values-in-order-to-make-it-float-real/106452/5 "2025-05-20T13:39:40Z")

</div>

No, that doesn't matter.

It does assume a "word order" that may need to be reversed, though.

---

<div class="post-metadata">

**Author:** ![viral.patel](https://avatars.discourse-cdn.com/v4/letter/v/fbc32d/32.png) [@viral.patel](https://forum.inductiveautomation.com/u/viral.patel)\
**Post date:** [May 20, 2025, 6:40pm UTC](https://forum.inductiveautomation.com/t/need-to-merge-two-int-values-in-order-to-make-it-float-real/106452/6 "2025-05-20T18:40:31Z")

</div>

i tried with this, but it is showing error with runscript

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/f/afdbd600bd50c25e9e3af815748892aba3b3ac09.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/b/cbc5828742776bb00fa3d024a5bb174e8fba5eb5.png)

so i entered direct value of integer to test, can you please guide

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 20, 2025, 6:51pm UTC](https://forum.inductiveautomation.com/t/need-to-merge-two-int-values-in-order-to-make-it-float-real/106452/7 "2025-05-20T18:51:53Z")

</div>

`runScript()` is part of the expression language. You would use it in a property binding or in an expression tag. If that latter, be sure your function is defined in the gateway scripting project (tags do not have access to all projects).
