×
Siemens Industry Online Support
Siemens AG
Entry type: FAQ Entry ID: 56600676, Entry date: 06/01/2015
(1)
Rate

How do you process 64-bit floating-point numbers in STEP 7 V5.5 with a SIMATIC S7-300/400 CPU?

  • Entry
  • Associated product(s)
Since it is not possible to directly process a 64-bit data type in a SIMATIC S7-300/400 CPU, you must convert it into a different data type for processing. Such a conversion can lead to loss of precision and/or limitation of the value range.

Description
It is not possible to directly process a 64-bit data type in a SIMATIC S7-300/400 CPU. You must therefore convert it into a different data type for processing. Such a conversion can lead to loss of precision and/or limitation of the value range. These restrictions are caused on the one hand by the reduced data type width of 32 bits and on the other hand by the representation of the approximation of all floating-point formats.

The STEP 7 program attached for downloading in this entry has four functions. These are for converting a 64-bit floating-point number (according to standard IEEE 754) into the data types below:

  • DINT (32-bit integer) for integer values (FC2)
  • REAL (32-bit floating point) for broken rational numbers (FC3)

and for converting to a 64-bit floating-point number from the data types below:

  • DINT (32-bit integer) for integer values (FC1)
  • REAL (32-bit floating point) for broken rational numbers (FC4)

 


Fig. 01: Structure of the STEP 7 program

 

The table below lists the interface parameters of the functions.
 

Name Type

Description

DINT2LREAL (FC1)
IN Input Input of the number value of the DINT data type
OUT Output Output of the number value of the LREAL data type
LREAL2DINT (FC2)
IN Input Input of the number value of the LREAL data type
Ret_Val Return Output of the number value of the DINT data type
STATUS Output Output of the status value*
LREAL2REAL (FC3)
IN Input Input of the number value of the LREAL data type
Ret_Val Return Output of the number value of the REAL data type
STATUS Output Output of the status value*
REAL2LREAL (FC4)
IN Input Input of the number value of the REAL data type
OUT Output Output of the number value of the LREAL data type

Table 1
* The status information is constructed bit for bit.

Table 2 lists the descriptions of the separate bits.
 

Bit no.Description
0LREAL value is greater than zero
1LREAL value is less than zero
2Overflow: LREAL value is greater than the greatest REAL value that can be displayed
3Underflow (denormalized range): LREAL value is less than the smallest REAL value that can be displayed. Value is rounded off to zero.
4Loss of information during conversion
5Reserved
6Warning
7

Error

Table 2

The STEP 7 program attached for downloading also contains a variable table. You can use this table to give values to the functions. 
   


Fig. 02: Excerpt from the variable table

Download
Registration required 64_bit_conversion.zip (282.2 KB)

Creation Environment
The download in this FAQ has been created with SIMATIC STEP 7 V5.5 + SP3.

Security information
In order to protect technical infrastructures, systems, machines and networks against cyber threats, it is necessary to implement – and continuously maintain – a holistic, state-of-the-art IT security concept. Siemens’ products and solutions constitute one element of such a concept. For more information about cyber security, please visit
https://www.siemens.com/cybersecurity#Ouraspiration.