# \[BUG-13231\] Write values to a long datatype, gets wrong value

**URL:** <https://forum.inductiveautomation.com/t/bug-13231-write-values-to-a-long-datatype-gets-wrong-value/23479>\
**Category:** Ignition\
**Created:** [March 20, 2019, 2:07pm UTC](https://forum.inductiveautomation.com/t/bug-13231-write-values-to-a-long-datatype-gets-wrong-value/23479 "2019-03-20T14:07:35Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![MartenS](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/martens/32/6407_2.png) [@MartenS](https://forum.inductiveautomation.com/u/MartenS)\
**Post date:** [March 20, 2019, 2:07pm UTC](https://forum.inductiveautomation.com/t/bug-13231-write-values-to-a-long-datatype-gets-wrong-value/23479/1 "2019-03-20T14:07:35Z")

</div>

Hi.

I’m having strange issues when writing big values to an tag of datatype long.

For example:  
If I copy this value: 20190320140538866 into my tag through “Tag Browser” it will be ok.  
If i write it from a script like this: _system.tag.write(‘Workorder/Database/ProdPlanNumber’,20190320140538866)_  
then the tag will get another value: 20190320140538864

If i write 20190320140538867 the tag will get value 20190320140538868.

Running 7.9.10  
Java 1.8.0\_66

Best Regards, Mårten

---

<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:** [March 20, 2019, 2:13pm UTC](https://forum.inductiveautomation.com/t/bug-13231-write-values-to-a-long-datatype-gets-wrong-value/23479/2 "2019-03-20T14:13:32Z")

</div>

Hmm. Must be coercion to `double` happening somewhere in Ignition after you pass the value to the scripting system.

---

<div class="post-metadata">

**Author:** ![MartenS](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/martens/32/6407_2.png) [@MartenS](https://forum.inductiveautomation.com/u/MartenS)\
**Post date:** [March 20, 2019, 2:19pm UTC](https://forum.inductiveautomation.com/t/bug-13231-write-values-to-a-long-datatype-gets-wrong-value/23479/3 "2019-03-20T14:19:46Z")

</div>

Tried it in Ignition 8.0beta also it behaves the same there.

---

<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:** [March 20, 2019, 2:20pm UTC](https://forum.inductiveautomation.com/t/bug-13231-write-values-to-a-long-datatype-gets-wrong-value/23479/4 "2019-03-20T14:20:49Z")

</div>

I made an issue to track this. At first glance this seems like a bug to me.

---

<div class="post-metadata">

**Author:** ![MartenS](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/martens/32/6407_2.png) [@MartenS](https://forum.inductiveautomation.com/u/MartenS)\
**Post date:** [March 21, 2019, 8:20am UTC](https://forum.inductiveautomation.com/t/bug-13231-write-values-to-a-long-datatype-gets-wrong-value/23479/5 "2019-03-21T08:20:04Z")

</div>

Hi.

I have made some more testing. if i’ll write a string value to an long (test-tag), the result is OK.  
system.tag.write(‘Workorder/Database/test’,20190320140538497) -Gets wrong result (20190320140538496)  
system.tag.write(‘Workorder/Database/test’,‘20190320140538497’) -Gets right result

So my workaround right now is to convert my long to a string:  
system.tag.write(‘Workorder/Database/ProdPlanNumber’,str(call.getOutParamValue(“PlanNumber”)))

Just for information.

Best Regars, Mårten

---

<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:** [March 21, 2019, 12:09pm UTC](https://forum.inductiveautomation.com/t/bug-13231-write-values-to-a-long-datatype-gets-wrong-value/23479/6 "2019-03-21T12:09:50Z")

</div>

> [@MartenS](#):
>
> system.tag.write(‘Workorder/Database/test’,20190320140538497)

Try using python's explicit long constant syntax:

```auto
system.tag.write(‘Workorder/Database/test’,20190320140538497L)

```

---

<div class="post-metadata">

**Author:** ![MartenS](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/martens/32/6407_2.png) [@MartenS](https://forum.inductiveautomation.com/u/MartenS)\
**Post date:** [March 21, 2019, 1:17pm UTC](https://forum.inductiveautomation.com/t/bug-13231-write-values-to-a-long-datatype-gets-wrong-value/23479/7 "2019-03-21T13:17:04Z")

</div>

Tried it, but still gets 20190320140538496 instead

---

<div class="post-metadata">

**Author:** ![Sanderd17](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sanderd17/32/8735_2.png) [@Sanderd17](https://forum.inductiveautomation.com/u/Sanderd17)\
**Post date:** [March 21, 2019, 1:37pm UTC](https://forum.inductiveautomation.com/t/bug-13231-write-values-to-a-long-datatype-gets-wrong-value/23479/8 "2019-03-21T13:37:11Z")

</div>

I guess somewhere in transit, either JSON or XML are used to encode data.

Those protocols typically encode a number as text.

These protocols by themselves have no hard limit on number size (see [http://json.org/](http://json.org/) as example), but libraries typically decode these as double-precision floating-point numbers. Since that’s the most generic number type.

---

<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:** [March 21, 2019, 1:38pm UTC](https://forum.inductiveautomation.com/t/bug-13231-write-values-to-a-long-datatype-gets-wrong-value/23479/9 "2019-03-21T13:38:00Z")

</div>

Hmm. That’s a bug. You should contact support.

---

<div class="post-metadata">

**Author:** ![MartenS](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/martens/32/6407_2.png) [@MartenS](https://forum.inductiveautomation.com/u/MartenS)\
**Post date:** [March 21, 2019, 2:14pm UTC](https://forum.inductiveautomation.com/t/bug-13231-write-values-to-a-long-datatype-gets-wrong-value/23479/10 "2019-03-21T14:14:37Z")

</div>

@Kevin.Herron already marked it as a bug and working on it I guess…

---

<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:** [March 21, 2019, 2:30pm UTC](https://forum.inductiveautomation.com/t/bug-13231-write-values-to-a-long-datatype-gets-wrong-value/23479/11 "2019-03-21T14:30:15Z")

</div>

Huh. I missed yesterday’s discussion somehow…
