LREAL type output wrong value

Dear Community.
I’m working on Real 64bit variable.
But I face of problem about if I force the variable by program the value is not correct.
Is there a limitation about programming 64bit value? or what is the proper way to do that?
I’ve tried with c language is working properly.

Hi,

on B&R Online Help all the way down, chapter Real literals (floating point) it says:

Real literals within the range of values of data type REAL (-3.4E38 to +3.4E38) are handled with the precision determined by the data type REAL. This is also the case when the real literal is assigned to a variable of data type LREAL or when the real literal is up-converted to LREAL.

1 Like

Hi,

in IEC61131-3 programming languages (e.g. Structured Text) a data type can be specified for a literal in this way: LREAL#1.12345678901

That seems not to work with Automation Basic.
If you start programming a new project/task, I suggest to use Structured Text instead of Automation Basic.

1 Like

ST aslo got the same result.
I’ve to go down to C programming instead

Hmm, checked it with AS 6 and ARM target. So it works as designed.

lReal : LREAL;
iReal : REAL;
lReal := LREAL#1.123456789012345;
iReal :=       1.123456789012345;


2 Likes

By the way, in C you can also provoke this by telling the compiler to interpret your literal as float by adding “F” at the end. By default it interprets it as double.

	test = 1.12345678901F;


image

1 Like