Byte Array to Real
Dear Unipi Support Team,
in a function block I want to assign a byte array (4Bytes) to a real? All variants I've tested ends in the normal int interpretation.
Martin Kudláček last edited by
what is the source of these 4 bytes? Do you read them from some HW prototype?
Hi Martin, from a tcp connection:
received := io.readport(handle, adr(dataRecv), 9);
I have a real of 4bytes in the byte array.
Martin Kudláček last edited by Martin Kudláček
we tried different approaches, but non of them gave the correct result. There doesn't seem to be a native way how to transform this data in ST code. It looks like you need to resort to the classic calculation according to: https://en.wikipedia.org/wiki/Single-precision_floating-point_format