In order to give you a good anwser, you need to be more specific as your question can be interpreted in twofold. I interpret you question with a simple anwser on face value;
Do you want INT A + INT B = REAL C?
rC := INT_TO_REAL( iA + iB);
If you want something more complex, please explain very specific what you want to accomplish.
Regards
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Your INT's (Bytes) allready have been 'marshalled' to hold IEE 754 bit and bitorder and you want to glue the bytes together again to get the original REAL (Float)
Are you using Profibus or MODBUS so?
Last edit: hermsen 2021-08-15
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ofcourse real3 will still be an integer value in that case.
Edit: Im not in front of an IDE right now so i assumed there is an Dint_to_real function, otherwise use a format that is convertable for the "diNewVar".
Last edit: ojz0r 2021-08-15
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I want to convert 2 diff INT datatype TO 1 Real datatype.
for example:
int1: int
int2:int
real3:real
How Can convert int1&int2 TO Real3?
Thanks
In order to give you a good anwser, you need to be more specific as your question can be interpreted in twofold. I interpret you question with a simple anwser on face value;
Do you want INT A + INT B = REAL C?
rC := INT_TO_REAL( iA + iB);
If you want something more complex, please explain very specific what you want to accomplish.
Regards
I have 2 different variable data type INT
I want to convert: 2 Bytes from the first var =INTA and 2 Bytes from the second var=INTB INTO REALC
Can I use it like:
TYPE Convert_2_int_to_byte :UNION
bytes: ARRAY [0..3] OF BYTE;
END_UNION
END_TYPE
TYPE Convert_Real_to_byte :UNION
a:REAL;
bytes: ARRAY [0..3] OF BYTE;
END_UNION
END_TYPE
nope...
Google for IEEE 754
https://en.wikipedia.org/wiki/IEEE_754
unless...
Your INT's (Bytes) allready have been 'marshalled' to hold IEE 754 bit and bitorder and you want to glue the bytes together again to get the original REAL (Float)
Are you using Profibus or MODBUS so?
Last edit: hermsen 2021-08-15
I am using MDLC.
I want to glue the bytes together INTA , INTB to get REALC(Float)
MDLC -> Google brings up nothing, what is a MDLC?
glue the bytes together INTA , INTB to get REALC(Float) -> Google for IEEE 754 to understand a float. https://en.wikipedia.org/wiki/IEEE_754
If you want no marshalling you can use the union solution you posted before
Last edit: hermsen 2021-08-15
If you define a new variable as Dint for example you can use:
Ofcourse real3 will still be an integer value in that case.
Edit: Im not in front of an IDE right now so i assumed there is an Dint_to_real function, otherwise use a format that is convertable for the "diNewVar".
Last edit: ojz0r 2021-08-15