title: PLC Structured text, convert decimal to real(float). Not getting the value I expect. (IEEE-754)
body: <p>I have a hardware that is communicating with the PLC over Profibus DP, that sends 
  me 4 bytes of data in hex that is "44 79 FF FF" and in the PLC program I have declared
  a BYTE array for this input data. The problem is in the PLC the data I receive in my BYTE
  array is "66 121 255 255" which is the decimal value of the hexdecimal, but my goal is to
  convert that value to a REAL and when I do that I'm not getting the value I expected.  </p>
  
  <p>I have created a DWORD(<strong><code>4bytesData</code></strong>) that i insert all the BYTES into.
  So before I insert the 4 bytes into <strong><code>4bytesData</code></strong> the bytes are: <code>in1 = 68</code> , <code>in2 = 121</code>, <code>in3 = 255</code> &amp; <code>in4 = 255</code></p>
  
  <pre><code>4bytesData := (SHL(SHL(SHL(BYTE_TO_DWORD(in1), 8) OR BYTE_TO_DWORD(in2), 8) OR     BYTE_TO_DWORD(in3), 8) OR in4);
  
  realValue := DWORD_TO_REAL(4bytesData);
  </code></pre>
  
  <p>Where in1, in2, in3 &amp; in4 is byte 0-3.</p>
  
  <p>The value I'm getting is; <strong><code>4bytesData</code></strong> = 1148846079 &amp; <strong><code>realValue</code></strong> = 1.148846e+009</p>
  
  <p>The value I'm expecting to get from <strong><code>realValue</code></strong> is = 9.9999993896484375E2</p>
  
  <p>If i use this website (
  <a href="http://babbage.cs.qc.cuny.edu/IEEE-754/index.xhtml" rel="nofollow">IEEE754 Analyzer/Converter</a> ) and converting the hex value (4479FFFF) I'm getting the value I want to, and if i insert the decimal value (1148846079) I'm getting the same value I receive in the PLC.</p>
  
  <p>I hope you understand my problem,
  Many thanks in Advance.   </p>