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

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

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

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

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

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

Try using python’s explicit long constant syntax:

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

Tried it, but still gets 20190320140538496 instead

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/ as example), but libraries typically decode these as double-precision floating-point numbers. Since that’s the most generic number type.

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

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

1 Like

Huh. I missed yesterday’s discussion somehow…