# 64-Bit Double Little Endian Input Register

**URL:** <https://forum.inductiveautomation.com/t/64-bit-double-little-endian-input-register/73987>\
**Category:** Ignition\
**Created:** [May 20, 2023, 1:12pm UTC](https://forum.inductiveautomation.com/t/64-bit-double-little-endian-input-register/73987 "2023-05-20T13:12:46Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![jasonpdavid](https://avatars.discourse-cdn.com/v4/letter/j/8edcca/32.png) [@jasonpdavid](https://forum.inductiveautomation.com/u/jasonpdavid)\
**Post date:** [May 20, 2023, 3:00pm UTC](https://forum.inductiveautomation.com/t/64-bit-double-little-endian-input-register/73987/21 "2023-05-20T15:00:18Z")

</div>

> [@Kevin.Herron](#):
>
> ```auto
> def double_le2(value):
> from java.lang import Double
> b0 = (value >> 56) & 0xFF
> b1 = (value >> 48) & 0xFF
> b2 = (value >> 40) & 0xFF
> b3 = (value >> 32) & 0xFF
> b4 = (value >> 24) & 0xFF
> b5 = (value >> 16) & 0xFF
> b6 = (value >> 8) & 0xFF
> b7 = (value >> 0) & 0xFF
> 	
> return Double.longBitsToDouble(b0 | b1 | b2 | b3 | b4 | b5 | b6 | b7)
> 
> ```

Returns Error\_ExpressionEval("Error executing script for runScript() expression:ByteUtil.double\_le2")  
on the tag with the script "runScript("ByteUtil.double\_le2", 0, {[~]1\_IR30001})". I didn't change the tag name but the OPC address is ns=1;s=[RedMeter]1.IRI\_6430001

The tags also return an Error\_TypeConversion with the data type as Integer. It returns a number when set to Long, Float, or Double though.

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

---

<div class="post-metadata">

**Author:** ![jasonpdavid](https://avatars.discourse-cdn.com/v4/letter/j/8edcca/32.png) [@jasonpdavid](https://forum.inductiveautomation.com/u/jasonpdavid)\
**Post date:** [May 20, 2023, 3:12pm UTC](https://forum.inductiveautomation.com/t/64-bit-double-little-endian-input-register/73987/22 "2023-05-20T15:12:21Z")

</div>

I may have forgotten to save after entering the new function. It isn't giving an error now but the value is still extremely small. I'm still playing with it to see if I can bring in another register.

The IRI\_64 is set as a Long currently and the expression tag is a Double.

---

<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, 2023, 3:14pm UTC](https://forum.inductiveautomation.com/t/64-bit-double-little-endian-input-register/73987/23 "2023-05-20T15:14:23Z")

</div>

My brain is embarrassing mush this morning. I can't be trusted with bit banging right now.

Try this:

```auto
def double_le2(value):
	from java.lang import Double
	b0 = (value >> 56) & 0xFF
	b1 = (value >> 48) & 0xFF
	b2 = (value >> 40) & 0xFF
	b3 = (value >> 32) & 0xFF
	b4 = (value >> 24) & 0xFF
	b5 = (value >> 16) & 0xFF
	b6 = (value >> 8) & 0xFF
	b7 = (value >> 0) & 0xFF
	
	return Double.longBitsToDouble(b0 | (b1 << 8) | (b2 << 16) | (b3 << 24) | (b4 << 32) | (b5 << 40) | (b6 << 48) | (b7 << 56))

```

Result should be 3.99 with the Long value from your screenshot.

---

<div class="post-metadata">

**Author:** ![jasonpdavid](https://avatars.discourse-cdn.com/v4/letter/j/8edcca/32.png) [@jasonpdavid](https://forum.inductiveautomation.com/u/jasonpdavid)\
**Post date:** [May 20, 2023, 3:16pm UTC](https://forum.inductiveautomation.com/t/64-bit-double-little-endian-input-register/73987/24 "2023-05-20T15:16:04Z")

</div>

> [@Kevin.Herron](#):
>
> ```auto
> def double_le2(value):
> from java.lang import Double
> b0 = (value >> 56) & 0xFF
> b1 = (value >> 48) & 0xFF
> b2 = (value >> 40) & 0xFF
> b3 = (value >> 32) & 0xFF
> b4 = (value >> 24) & 0xFF
> b5 = (value >> 16) & 0xFF
> b6 = (value >> 8) & 0xFF
> b7 = (value >> 0) & 0xFF
> 	
> return Double.longBitsToDouble(b0 | (b1 << 8) | (b2 << 16) | (b3 << 24) | (b4 << 32) | (b5 << 40) | (b6 << 48) | (b7 << 56))
> 
> ```

My HERO!!!

---

<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, 2023, 3:17pm UTC](https://forum.inductiveautomation.com/t/64-bit-double-little-endian-input-register/73987/25 "2023-05-20T15:17:28Z")

</div>

Ooph, insult to injury, making it harder on myself all along:

```auto
def double_le3(value):
	from java.lang import Long
	from java.lang import Double
	
	return Double.longBitsToDouble(Long.reverseBytes(value))

```

Stepping away from the computer before I do more damage 😆

---

<div class="post-metadata">

**Author:** ![jasonpdavid](https://avatars.discourse-cdn.com/v4/letter/j/8edcca/32.png) [@jasonpdavid](https://forum.inductiveautomation.com/u/jasonpdavid)\
**Post date:** [May 20, 2023, 3:19pm UTC](https://forum.inductiveautomation.com/t/64-bit-double-little-endian-input-register/73987/26 "2023-05-20T15:19:35Z")

</div>

> [@Kevin.Herron](#):
>
> ```auto
> def double_le3(value):
> from java.lang import Long
> from java.lang import Double
> 	
> return Double.longBitsToDouble(Long.reverseBytes(value))
> 
> ```

That worked as well. Time for more coffee. Thanks again @Kevin.Herron

[Previous page](https://forum.inductiveautomation.com/t/64-bit-double-little-endian-input-register/73987.md?page=1)
